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

Add -rr/--reverse-relative option (issue #417) #867

Merged
merged 1 commit into from
Mar 2, 2019

Conversation

jpgrayson
Copy link
Contributor

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

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>
@timothycrosley
Copy link
Member

This is great,

Thank you!

@timothycrosley timothycrosley changed the base branch from develop to master March 2, 2019 09:55
@timothycrosley timothycrosley changed the base branch from master to develop March 2, 2019 09:56
@timothycrosley timothycrosley merged commit 12588b4 into PyCQA:develop Mar 2, 2019
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.

2 participants