-
Notifications
You must be signed in to change notification settings - Fork 105
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
Sort import statements within project #777
Conversation
tests/fixtures/common/collections/ansible_collections/testorg/coll_1/plugins/lookup/lookup_1.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per slack discussions, let's implement #778 in a standalone prerequisite PR so that there is at least a basic sanity check for whether this big patch introduces any obvious import loops.
Test for circular imports in project Resolves: #778 Test for circular imports in all local packages and modules. This ensures all internal packages can be imported right away without any need to import some other module before doing so. Related: #777 Reviewed-by: Sviatoslav Sydorenko <webknjaz+github/profile@redhat.com> Reviewed-by: None <None> Reviewed-by: Sorin Sbarnea <sorin.sbarnea@gmail.com> Reviewed-by: Bradley A. Thornton <bthornto@redhat.com>
tests/fixtures/common/collections/ansible_collections/testorg/coll_1/plugins/modules/mod_1.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
for more information, see https://pre-commit.ci
tests/fixtures/common/collections/ansible_collections/testorg/coll_1/plugins/lookup/lookup_1.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Change the order of relative imports This modifies the order of relative import statements. Fixes: #780 Prior to this change the order was import .sibling import ..parent import ...grandparent after this change import ...grandparent import ..parent import .sibling The resulting order is the default for isort which decreases the amount of custom configuration within the repo and results in a sorting order starting with "least local" to "most local". This follow on work after #777, which was intended to minimize the changes in the repo related to the cleanup. #779 was also implemented to help detect any issues arising from a change in order. Some conversation and history about the ordering can be found here: PyCQA/isort#417 Reviewed-by: Sviatoslav Sydorenko <webknjaz+github/profile@redhat.com> Reviewed-by: None <None>
Change the order of relative imports This modifies the order of relative import statements. Fixes: ansible#780 Prior to this change the order was import .sibling import ..parent import ...grandparent after this change import ...grandparent import ..parent import .sibling The resulting order is the default for isort which decreases the amount of custom configuration within the repo and results in a sorting order starting with "least local" to "most local". This follow on work after ansible#777, which was intended to minimize the changes in the repo related to the cleanup. ansible#779 was also implemented to help detect any issues arising from a change in order. Some conversation and history about the ordering can be found here: PyCQA/isort#417 Reviewed-by: Sviatoslav Sydorenko <webknjaz+github/profile@redhat.com> Reviewed-by: None <None>
pyproject.toml
(a default location for isort configuration).flake8
tox -e lint-vetting
After several iterations this configuration for
isort
was found to most closely align with the current sort order and minimize the number of changes.Note:
isort
configurationpre-commit
config out oftox lint-vetting
totox lint
and modify the contributors guidepyproject.toml
file for an explanation of each settingreverse_relative
settings will be remove in a follow-up PR, issue Removereverse_relative
frompyproject.toml
(isort) after initial PR. #780Closes #715