-
-
Notifications
You must be signed in to change notification settings - Fork 584
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
Relative import sorting order #417
Comments
Hi @lee-kagiso, Thanks for bringing this to my attention! This is not something isort currently supports, but I'll work on adding support for this in the next release. Thanks! ~Timothy |
This is fixed as the default (no config necessary) and will be pushed into a new release today. Thanks! ~Timothy |
Let me start by saying thank you for Although the referenced
To be clear, by descending order, I mean: from ...baz import x
from ..foo import y
from .bar import z There are at least two arguments for
The original intent of this issue was to add an option to select the order of relative imports. I suggest that such an option remains a valid request for |
I agree with @jpgrayson, with the recent release of isort it suddenly started reversing imports that were perfectly fine before. |
This new option changes the sort order of relative imports. The new default sort order is from furthest to closest (most dots to least dots): from ... import a from ...foo import x from .. import b from ..bar import y from . import c from .baz import z With the new -rr/--reverse-relative option, the order of the relative import *levels* (inter-order) is reversed, but the ordering within each relative import level (intra-order) remains the same (i.e. normal lexical order). from . import c from .baz import z from .. import b from ..bar import y from ... import a from ...foo import x Signed-off-by: Peter Grayson <pete@jpgrayson.net>
Add -rr/--reverse-relative option (issue #417)
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>
Is there a setting to change the sort order of relative imports from
to
so that one can comply with the Google style guide as per this linter https://github.com/public/flake8-import-order#configuration?
The text was updated successfully, but these errors were encountered: