Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config #1903

Merged
merged 30 commits into from
Sep 30, 2020
Merged

Update config #1903

merged 30 commits into from
Sep 30, 2020

Conversation

tomaszdrozdz
Copy link
Contributor

No description provided.

@tomaszdrozdz
Copy link
Contributor Author

Please look at discusion here: (#1895)

Copy link
Member

@ahopkins ahopkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I like the direction. Don't forget:

  1. Tests
  2. Documentation changes

sanic/config.py Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
@tomaszdrozdz
Copy link
Contributor Author

tomaszdrozdz commented Aug 4, 2020

OK I will do more needed work like documentation (perhaps next week because I will be off for few days).
So far I just wanted to see how You like it :-)

sanic/utils.py Outdated Show resolved Hide resolved
@tomaszdrozdz
Copy link
Contributor Author

Please review, comment, advise.
If all is OK I will move to documenting it.
(Then to tests).

sanic/utils.py Outdated Show resolved Hide resolved
Copy link
Member

@ahopkins ahopkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A couple of small points.

sanic/config.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/config.py Outdated
import types
from os import environ as os_environ

from typing import Union, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that you're using \ charachter here in order to avoid linter errors, am I right? Also, in my opinion would be better to use this format

from typing import Union, Any

# OR

from typing import (Union, Any)

Copy link
Contributor Author

@tomaszdrozdz tomaszdrozdz Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it just looks nicer to read.
But if You do not like it - we can do as You like.
Just decide and let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official stance is that you should run black and isort. We do not need to make these decisions about style choice then 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the black and isort will do the job for us ?

Copy link
Contributor

@myusko myusko Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually isort usually doing formatting which I've mentioned above, you need to run black/isort and it will do all necessary formatting, etc.

Copy link
Member

@ahopkins ahopkins Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a command to run this in the Makefile. I usually run make fix-import which (contrary to the name) also runs black. Probably worth a fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should not bother much about it because during "building process" it will be "blacked" and "isorted" anyway ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should manually run make black and make fix-import commands.

Copy link
Contributor Author

@tomaszdrozdz tomaszdrozdz Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I runned: "make fix-import".
But it changed not only imports - please take a look.
So perhaps fix-import should only fix imports,
and there should be another target that would fix-imports and do other stuff (stuff that now fix-import does).

sanic/config.py Outdated Show resolved Hide resolved
sanic/utils.py Outdated Show resolved Hide resolved
sanic/utils.py Outdated Show resolved Hide resolved
sanic/utils.py Outdated Show resolved Hide resolved
sanic/utils.py Outdated Show resolved Hide resolved
@sanic-org sanic-org deleted a comment from myusko Aug 18, 2020
sanic/config.py Outdated Show resolved Hide resolved
sanic/exceptions.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/deprecated.py Outdated Show resolved Hide resolved
sanic/config.py Outdated Show resolved Hide resolved
sanic/deprecated.py Outdated Show resolved Hide resolved
sanic/deprecated.py Outdated Show resolved Hide resolved
@ashleysommer
Copy link
Member

@tomaszdrozdz We want to try to get this merged in before the 2020-09 release. How are you progressing with those final changes requested last week?

@tomaszdrozdz
Copy link
Contributor Author

tomaszdrozdz commented Sep 24, 2020

I found something,
Just for now run with pytest, not tox.

When I run:

python -m pytest tests/test_load_module_from_file_location.py tests/test_update_config.py

test_load_module_from_file_location from tests/test_load_module_from_file_location.py is run first so all tests pass.
but when I run:

python -m tests/test_update_config.py pytest tests/test_load_module_from_file_location.py

then test_update from ests/test_update_config.py pytest is skipped
because test_load_module_from_file_location from tests/test_load_module_from_file_location.py has not been runed yet.

Can we force somehow test execution order ?

I have found this:
https://pytest-ordering.readthedocs.io/en/develop/

@tomaszdrozdz
Copy link
Contributor Author

Quick tox how to please ?

@tomaszdrozdz
Copy link
Contributor Author

And apologize for being absent.
I have been quite busy.

@ahopkins
Copy link
Member

Thanks, will look and try to merge tomorrow night before next week's release.

@ahopkins
Copy link
Member

Quick tox how to please ?

How to what?

@ahopkins
Copy link
Member

then test_update from ests/test_update_config.py pytest is skipped
because test_load_module_from_file_location from tests/test_load_module_from_file_location.py has not been runed yet.

Needing to run tests in a specific order sounds to me like there is a problem with the underlying tests.

@tomaszdrozdz
Copy link
Contributor Author

tomaszdrozdz commented Sep 28, 2020

Needing to run tests in a specific order sounds to me like there is a problem with the underlying tests.

Do not quite understand what kind of problem You can think of ?

Pytest by default runs test in order they are discovered - so it takes into account directories names, files names, order of test in a module.
So because
  test_load_module_from_file_location.py
alphabetically is before
  test_update_config.py
then
  test_load_module_from_file_location()
is runned before
  test_update().

But if we change this tests files names so they switch alphabetically order we will run test_update() before test_load_module_from_file_location() so it will be skipped.

Unfortunately https://pytest-ordering.readthedocs.io/en/develop/ seams to be more of "I wish to have" then actual work done.


We can not to use pytest dependencies, but then we get different issue:
if
  test_load_module_from_file_location()
fails, then
  test_update()
and
  test_loaded_module_from_file_location_name
will also fail instead of just being skipped.

@tomaszdrozdz
Copy link
Contributor Author

tomaszdrozdz commented Sep 28, 2020

And about tox - hot to run test with tox:

pip install tox
tox ???

@myusko
Copy link
Contributor

myusko commented Sep 28, 2020

And about tox - hot to run test with tox:

pip install tox
tox ???

Yes, you are almost right, but you should install it.

Please, see https://sanic.readthedocs.io/en/latest/sanic/contributing.html

@ahopkins
Copy link
Member

And about tox - hot to run test with tox:

pip install tox
tox ???

Sanic is setup to run tests on 3.6, 3.7, and 3.8. You can limit it in tox to just one of them:

tox -e py38

@ahopkins
Copy link
Member

Need any help on this? I want to merge it on today/tomorrow (2020-09-29.)

@tomaszdrozdz
Copy link
Contributor Author

Currently I work on system where highest python version is 3.5.
So I guess tox will not be able to create virtual env fro python 3.6, 3.7, 3.8 like specified in tox.ini.

Tu run any python version I use conda

To be honest there are some efforts to make tox work with conda - but have not tried it.

So please, please if You think this pull request changes are ready to merge to master
please run tox instead of me.


As I can see in "tarvis" check

  • there are some "type checks" error that I do not understand
  • and linter errors for python 3.6 - can we allow them ?

And some errors for appveyor for -no-ext python 3.6, 3.7, 3.8 - but I do not know what it means.

@ahopkins
Copy link
Member

OK. I'll take a look tonight and try and take a pass at it.

@ahopkins
Copy link
Member

@tomaszdrozdz I want to say that I think you did a bang up job on this. Thanks for all the back and forth and patience with all the comments.

)
except IOError as e:
e.strerror = f"Unable to load configuration file (e.strerror)"
e.strerror = "Unable to load configuration file (e.strerror)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be ?:

        e.strerror = "Unable to load configuration file {e.strerror}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahopkins @myusko
Do not know if it is to late, but this is not "bleeding bug", but please also take a look.

@tomaszdrozdz
Copy link
Contributor Author

@ahopkins @myusko @ashleysommer @tigerthelion
Thank You all I could contribute to OpenSource Sanic 🥇
It was a great adventure with nice fellows.
And thank You for all Your kind help, comments and discussions. :-)

@ahopkins ahopkins merged commit 1de4bce into sanic-org:master Sep 30, 2020
@ahopkins ahopkins mentioned this pull request Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants