Skip to content

Commit

Permalink
Fine-grained: Fix crash caused by unreachable class (python#4613)
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL authored and yedpodtrzitko committed Mar 13, 2018
1 parent a93bc3a commit a685d57
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mypy/server/astmerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions test-data/unit/fine-grained.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]
==

0 comments on commit a685d57

Please sign in to comment.