Skip to content

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

Merged
JukkaL merged 1 commit into
masterfrom
fix-self-dep
Aug 14, 2020
Merged

JukkaL merged 1 commit into
masterfrom
fix-self-dep

Conversation

@msullivan

@msullivan msullivan commented Aug 13, 2020 •

Copy link
Copy Markdown
Collaborator

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.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread mypy/dmypy_server.py
# 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
Copy Markdown
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