Skip to content

Commit 5a08ce1

Browse files
committed
Signal unreachability when narrowing with Type{Guard,Is}[Never]
1 parent 7f3d7f8 commit 5a08ce1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mypy/checker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5889,9 +5889,13 @@ def find_isinstance_check_helper(
58895889
# Also note that a care must be taken to unwrap this back at read places
58905890
# where we use this to narrow down declared type.
58915891
if node.callee.type_guard is not None:
5892+
if isinstance(get_proper_type(node.callee.type_guard), UninhabitedType):
5893+
return None, {}
58925894
return {expr: TypeGuardedType(node.callee.type_guard)}, {}
58935895
else:
58945896
assert node.callee.type_is is not None
5897+
if isinstance(get_proper_type(node.callee.type_is), UninhabitedType):
5898+
return None, {}
58955899
return conditional_types_to_typemaps(
58965900
expr,
58975901
*self.conditional_types_with_intersection(

0 commit comments

Comments
 (0)