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

Reprocess a module if a previously missing import was added #7199

Merged
merged 4 commits into from Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/server/deps.py
Expand Up @@ -333,6 +333,7 @@ def visit_import_from(self, o: ImportFrom) -> None:
o.relative,
o.id,
self.is_package_init_file)
self.add_dependency(make_trigger(module_id)) # needed if module is added/removed
for name, as_name in o.names:
self.add_dependency(make_trigger(module_id + '.' + name))

Expand Down
2 changes: 1 addition & 1 deletion mypy/test/testdeps.py
Expand Up @@ -65,7 +65,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
TypeState.add_all_protocol_deps(deps)

for source, targets in sorted(deps.items()):
if source.startswith('<enum.'):
if source.startswith(('<enum', '<typing', '<mypy')):
# Remove noise.
continue
line = '%s -> %s' % (source, ', '.join(sorted(targets)))
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/deps-classes.test
Expand Up @@ -22,6 +22,7 @@ class A: pass
<m.N.a> -> m.f
<m.N> -> m.f
<a.A> -> <m.N.a>, <m.N>, m
<a> -> m

[case testNamedTuple2]
from typing import NamedTuple, Any, Tuple
Expand All @@ -41,6 +42,7 @@ class B: pass
<m.N> -> m.f
<a.A> -> <m.N.a>, <m.N>, m
<a.B> -> <m.N.a>, <m.N>, m
<a> -> m

[case testNamedTuple3]
from typing import NamedTuple
Expand Down Expand Up @@ -75,6 +77,7 @@ class A: pass
<m.N.a> -> m.f
<m.N> -> m.N, m.f
<a.A> -> <m.N.a>, <m.N>, m, m.N
<a> -> m

[case testIfFalseInClassBody]
class A:
Expand Down Expand Up @@ -178,6 +181,7 @@ class B: pass
<m.B.__new__> -> m
-- The <m.A.X> dependecy target is superfluous but benign
<m.B> -> <m.A.X>, m
<m> -> m

[case testClassAttribute]
class C:
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/deps-statements.test
Expand Up @@ -681,3 +681,4 @@ class C:
<m.C.__new__> -> <m.N.__new__>
<m.C.x> -> <m.N.x>
<m.C> -> m, m.N
<m> -> m
37 changes: 37 additions & 0 deletions test-data/unit/deps-types.test
Expand Up @@ -175,6 +175,7 @@ class C(metaclass=M):
<mod.C.x> -> m.f
<mod.C> -> <m.f>, m, m.f
<mod.M.x> -> m.f
<mod> -> m

[case testMetaclassAttributesDirect]
from mod import C
Expand All @@ -189,6 +190,7 @@ class C(metaclass=M):
<mod.C.x> -> m.f
<mod.C> -> m, m.f
<mod.M.x> -> m.f
<mod> -> m

[case testMetaclassOperators]
from mod import C
Expand All @@ -207,6 +209,7 @@ class C(metaclass=M):
<mod.C> -> <m.f>, m, m.f
<mod.M.__add__> -> m.f
<mod.M.__radd__> -> m.f
<mod> -> m

[case testMetaclassOperatorsDirect]
from mod import C
Expand All @@ -224,6 +227,7 @@ class C(metaclass=M):
<mod.C> -> m, m.f
<mod.M.__add__> -> m.f
<mod.M.__radd__> -> m.f
<mod> -> m

[case testMetaclassDepsDeclared]
import mod
Expand Down Expand Up @@ -284,6 +288,7 @@ class C:
<mod.C.x> -> m.f
<mod.C> -> <m.f>, m, m.f
<mod.M.x> -> m.f
<mod> -> m

[case testMetaclassOperatorsDirect_python2]
# flags: --py2
Expand All @@ -304,6 +309,7 @@ class C:
<mod.C> -> m, m.f
<mod.M.__add__> -> m.f
<mod.M.__radd__> -> m.f
<mod> -> m

-- Type aliases

Expand All @@ -319,6 +325,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.x>, m
<mod> -> m

[case testAliasDepsNormalModExtended]
# __dump_all__
Expand All @@ -336,6 +343,7 @@ class I: pass
<mod.I.__init__> -> a
<mod.I.__new__> -> a
<mod.I> -> <m.x>, m, a, mod.I
<mod> -> a

[case testAliasDepsNormalFunc]
from mod import I
Expand All @@ -349,6 +357,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.f>, m, m.f
<mod> -> m

[case testAliasDepsNormalFuncExtended]
# __dump_all__
Expand All @@ -366,6 +375,7 @@ class I: pass
<mod.I.__init__> -> a
<mod.I.__new__> -> a
<mod.I> -> <m.f>, m.f, a, mod.I
<mod> -> a

[case testAliasDepsNormalClass]
from a import A
Expand All @@ -379,6 +389,7 @@ class I: pass
[out]
<m.C> -> m.C
<a.A> -> m
<a> -> m
<mod.I> -> <m.C.x>, m

[case testAliasDepsNormalClassBases]
Expand All @@ -393,6 +404,7 @@ class I: pass
[out]
<m.C> -> m.C
<a.A> -> m
<a> -> m
<mod.I.(abstract)> -> <m.C.__init__>, m
<mod.I.__init__> -> <m.C.__init__>
<mod.I.__new__> -> <m.C.__new__>
Expand All @@ -417,6 +429,7 @@ class S: pass
<mod.D> -> <m.x>, m
<mod.I> -> <m.x>, m
<mod.S> -> <m.x>, m
<mod> -> m

[case testAliasDepsGenericFunc]
from mod import I, S, D
Expand All @@ -437,6 +450,7 @@ class S: pass
<mod.D> -> <m.f>, m, m.f
<mod.I> -> <m.f>, m, m.f
<mod.S> -> <m.f>, m, m.f
<mod> -> m

[case testAliasDepsGenericFuncExtended]
import a
Expand Down Expand Up @@ -480,6 +494,7 @@ class S: pass
<mod.I> -> <m.C.x>, m
<mod.S> -> <m.C.x>, m
<mod.T> -> m
<mod> -> m

[case testAliasDepsForwardMod]
from mod import I
Expand All @@ -494,6 +509,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.x>, m
<mod> -> m

[case testAliasDepsForwardFunc]
from mod import I
Expand All @@ -507,6 +523,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.f>, m, m.f
<mod> -> m

[case testAliasDepsForwardClass]
from mod import I
Expand All @@ -521,6 +538,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.C.x>, m
<mod> -> m

[case testAliasDepsChainedMod]
from mod import I
Expand All @@ -536,6 +554,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.x>, m
<mod> -> m

[case testAliasDepsChainedFunc]
from mod import I
Expand All @@ -551,6 +570,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.f>, m, m.f
<mod> -> m

[case testAliasDepsChainedFuncExtended]
import a
Expand Down Expand Up @@ -586,6 +606,7 @@ class I: pass
<mod.I.__init__> -> <m.C.__init__>, m
<mod.I.__new__> -> <m.C.__new__>, m
<mod.I> -> m, m.C
<mod> -> m

[case testAliasDepsNestedMod]
from mod import I, S, D
Expand All @@ -608,6 +629,7 @@ class S: pass
<mod.D> -> <m.x>, m
<mod.I> -> <m.x>, m
<mod.S> -> <m.x>, m
<mod> -> m

[case testAliasDepsNestedModExtended]
# __dump_all__
Expand Down Expand Up @@ -637,6 +659,7 @@ class S: pass
<mod.S> -> <m.x>, m, a, mod.S
<mod.T> -> mod.D
<mod.U> -> mod.D
<mod> -> m, a

[case testAliasDepsNestedFunc]
from mod import I, S, D
Expand All @@ -659,6 +682,7 @@ class S: pass
<mod.D> -> <m.f>, m, m.f
<mod.I> -> <m.f>, m, m.f
<mod.S> -> <m.f>, m, m.f
<mod> -> m

[case testAliasDepsNestedFuncExtended]
# __dump_all__
Expand Down Expand Up @@ -688,6 +712,7 @@ class S: pass
<mod.S> -> <m.f>, m, m.f, a, mod.S
<mod.T> -> mod.D
<mod.U> -> mod.D
<mod> -> m, a

[case testAliasDepsNestedFuncDirect]
from mod import I, S, D
Expand All @@ -712,6 +737,7 @@ class S: pass
<mod.S> -> <m.f>, m, m.f
<mod.T> -> m
<mod.U> -> m
<mod> -> m

[case testAliasDepsNestedClass]
from mod import I, S, D
Expand All @@ -735,6 +761,7 @@ class S: pass
<mod.D> -> <m.C.x>, m
<mod.I> -> <m.C.x>, m
<mod.S> -> <m.C.x>, m
<mod> -> m

[case testAliasDepsCast]
from typing import cast
Expand All @@ -754,6 +781,7 @@ class S: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> m, m.fun
<mod> -> m

[case testAliasDepsRuntime]
from mod import I, S, D
Expand All @@ -776,6 +804,7 @@ class S: pass
<mod.I.__new__> -> m
<mod.I> -> <m.x>, m
<mod.S> -> <m.x>, m
<mod> -> m

[case testAliasDepsRuntimeExtended]
# __dump_all__
Expand Down Expand Up @@ -805,6 +834,7 @@ class S: pass
<mod.S> -> <m.x>, m, mod.S
<mod.T> -> mod.D
<mod.U> -> mod.D
<mod> -> m, a

[case testAliasDepsNamedTuple]
from typing import NamedTuple
Expand All @@ -820,6 +850,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.P.x>, <m.P>, m, m.P
<mod> -> m

[case testAliasDepsNamedTupleFunctional]
# __dump_all__
Expand All @@ -837,6 +868,7 @@ class I: pass
<mod.I.__init__> -> a
<mod.I.__new__> -> a
<mod.I> -> <m.P.x>, <m.P>, m, a, mod.I
<mod> -> a

[case testAliasDepsTypedDict]
from mypy_extensions import TypedDict
Expand All @@ -853,6 +885,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.P>, m
<mod> -> m

[case testAliasDepsTypedDictFunctional]
# __dump_all__
Expand All @@ -871,6 +904,7 @@ class I: pass
<mod.I.__init__> -> a
<mod.I.__new__> -> a
<mod.I> -> <m.P>, a, mod.I
<mod> -> a
<sys.platform> -> sys
<sys.version_info> -> sys

Expand All @@ -888,6 +922,7 @@ class I: pass
<mod.I.__init__> -> m
<mod.I.__new__> -> m
<mod.I> -> <m.f.x>, m, m.f
<mod> -> m

[case testAliasDepsFromImportUnqualified]
from a import C
Expand All @@ -908,6 +943,7 @@ class D:
<m.A> -> m.A
<m.x> -> m
<a.C> -> m, m.A.meth, m.f
<a> -> m
<b.D.__init__> -> m.f
<b.D.__new__> -> m.f
<b.D> -> <m.A.meth>, <m.x>, m, m.A.meth
Expand All @@ -928,6 +964,7 @@ class B: pass
<m.A.X> -> m.g
<m.A> -> <m.f>, m.f, m.g
<mod.B> -> m
<mod> -> m

[case testProtocolDepsWildcard]
# __dump_all__
Expand Down