Skip to content

Make import cycles more predictable by prioritizing different import forms #1736

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

Merged
merged 9 commits into from
Jun 27, 2016

Conversation

gvanrossum
Copy link
Member

Partially fixes #1530.

Guido van Rossum added 8 commits June 21, 2016 20:13
Add unit tests proving that it has a beneficial effect.

The new algorithm always processes x before y, while the old one gives
an error when y is processed before x:
```
x.py:4: note: In module imported here:
y.py: note: In class "Sub":
y.py:3: error: Cannot determine type of 'attr'
```
@gvanrossum
Copy link
Member Author

I think this is as far as I'd like to take this for now.

There are a few errors in our internal repos that I have to look into.

# suppressed contains those reachable imports that were prevented by
# --silent-imports or simply not found.


# Priorities used for imports. (Here, top-level includes inside a class.)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe mention what priorities are used for and why.

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 27, 2016

Looks good, but look at the notes above. Also it would be nice to have tests that cover all the possible priorities in some way.

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 27, 2016

Looks good now! Feel free to merge once you have a green build.

@gvanrossum gvanrossum merged commit 9a92899 into master Jun 27, 2016
@gvanrossum gvanrossum deleted the import-cycles branch June 27, 2016 19:21
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.

Sort modules in dependency cycles based on dependencies
2 participants