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

Don't infinite loop on self deps in --follow-imports=normal #9302

Merged
merged 1 commit into from
Aug 14, 2020

Conversation

msullivan
Copy link
Collaborator

@msullivan msullivan commented Aug 13, 2020

There are situations in complex SCCs where the semantic analyzer will
infer self dependencies, which will cause an infinite loop in dmypy
--follow-imports=normal.

It's probably a bug that we do that, and that should be fixed too, but
fixing a graph algorithm to not infinite loop on self edges seems like
a reasonable thing to do in any case.

I don't have a minimized test case yet, and am submitting this without
one because it should be harmless and because I want it to get into
the release.

There are situations in complex SCCs where the semantic analyzer will
infer self dependencies, which will cause an infinite loop in dmypy
--follow-imports=normal.

It's probably a bug that we do that, and that should be fixed to, but
fixing a graph algorithm to not infinite loop on self edges seems like
a reasonable thing to do in any case.

I don't have a minimized test case yet, and am submitting this without
one because it should be harmless and because I want it to get into
the release.
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks!

I left suggestion about an alternative way of fixing this, but I'm going to merge this as is since I want this for the release. If you think that the suggestion is good, this can be tweaked in a follow-up PR.

# Filter anything already seen before. This prevents
# infinite looping if there are any self edges. (Self
# edges are maybe a bug, but...)
sources2 = [source for source in sources2 if source.module not in seen]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be better to do this filtering in direct_imports?

@JukkaL JukkaL merged commit c2c72da into master Aug 14, 2020
@JelleZijlstra JelleZijlstra deleted the fix-self-dep branch August 16, 2020 02:16
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