Skip to content

Fine-grained: Fix crash caused by unreachable class #4613

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 1 commit into from
Feb 21, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
==