diff --git a/mypy/server/astmerge.py b/mypy/server/astmerge.py index 511c3b685e9e..3d13edac14bc 100644 --- a/mypy/server/astmerge.py +++ b/mypy/server/astmerge.py @@ -254,7 +254,9 @@ def fixup(self, node: SN) -> SN: def fixup_type(self, typ: Type) -> None: typ.accept(TypeReplaceVisitor(self.replacements)) - def process_type_info(self, info: TypeInfo) -> None: + def process_type_info(self, info: Optional[TypeInfo]) -> None: + if info is None: + return # TODO: Additional things: # - declared_metaclass # - metaclass_type diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index 59ddaf3a6b47..590e978e3ef7 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -1861,3 +1861,59 @@ def f() -> None: [out] a.py:1: error: Need type annotation for 'y' == + +[case testSkippedClass1] +import a +[file a.py] +class A: pass +[file a.py.2] +import sys +if sys.platform == 'xyz': + class A: pass +[builtins fixtures/ops.pyi] +[out] +== + +[case testSkippedClass2] +import a +[file a.py] +import sys +if sys.platform == 'xyz': + class A: pass +[file a.py.2] +import sys +if sys.platform == 'xyz': + class A: pass +[builtins fixtures/ops.pyi] +[out] +== + +[case testSkippedClass3] +import a +[file a.py] +import sys +if sys.platform == 'xyz': + class A: pass +[file a.py.2] +class A: pass +[builtins fixtures/ops.pyi] +[out] +== + +[case testSkippedClass4] +import a +[file a.py] +import sys +if sys.platform == 'xyz': + class A: pass +else: + class A: pass +[file a.py.2] +import sys +if sys.platform == 'xyz': + class A: pass +else: + class A: pass +[builtins fixtures/ops.pyi] +[out] +==