8000 New semantic analyzer: store import deps generated during analysis by JukkaL · Pull Request #6582 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

New semantic analyzer: store import deps generated during analysis #6582

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 3 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
New semantic analyzer: store import deps generated during analysis
Previously some module dependencies genererated from `from m import *`
went missing, and this could result in crashes when deserialization,
since the target module wasn't serialized yet.

This fixes one incremental mode test case.
  • Loading branch information
JukkaL committed Mar 22, 2019
commit 0782c3d9db7f3778a629fdec4c41a15faa1e214f
4 changes: 4 additions & 0 deletions mypy/newsemanal/semanal_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from mypy.errors import Errors
from mypy.newsemanal.semanal_infer import infer_decorator_signature_if_simple
from mypy.checker import FineGrainedDeferredNode
import mypy.build

MYPY = False
if MYPY:
Expand Down Expand Up @@ -278,6 +279,9 @@ def semantic_analyze_target(target: str,
analyzer.refresh_partial(refresh_node, patches, final_iteration)
if isinstance(node, Decorator):
infer_decorator_signature_if_simple(node, analyzer)
for dep in analyzer.imports:
state.dependencies.append(dep)
state.priorities[dep] = mypy.build.PRI_LOW
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no checking against what is already a dependency, so can this result in things ending up in the dependency list multiple times or having the priority clobbered?
(Though I suppose we hope that the priority does not matter with the new semantic analyzer, right?)

if analyzer.deferred:
return [target], analyzer.incomplete, analyzer.progress
else:
Expand Down
15 changes: 15 additions & 0 deletions test-data/unit/check-newsemanal.test
Original file line number Diff line number Diff line change
Expand Up @@ -2020,3 +2020,18 @@ class C(Generic[T]): ...

class A: ...
class D: ...

[case testNewAnalyzerAddedSubStarImport_incremental]
# TODO: This can be removed once testAddedSubStarImport is enabled in check-incremental.test.
# cmd: mypy -m a pack pack.mod b
# cmd2: mypy -m other
[file a.py]
from pack import *
[file pack/__init__.py]
[file pack/mod.py]
[file b.py]
import pack.mod
[file other.py]
import a
[out]
[out2]
0