Skip to content

Commit 1519190

Browse files
Fix python#18423 - reveal_type not run in "unreachable" branches
1 parent bac9984 commit 1519190

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mypy/messages.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,13 @@ def invalid_signature_for_special_method(
17491749

17501750
def reveal_type(self, typ: Type, context: Context) -> None:
17511751
visitor = TypeStrVisitor(options=self.options)
1752-
self.note(f'Revealed type is "{typ.accept(visitor)}"', context)
1752+
proper_type = get_proper_type(typ) # Resolve any type aliases or partial types
1753+
1754+
# Check if the type is UninhabitedType (unreachable code)
1755+
if isinstance(proper_type, UninhabitedType):
1756+
self.note('Revealed type is "Never"', context)
1757+
else:
1758+
self.note(f'Revealed type is "{proper_type.accept(visitor)}"', context)
17531759

17541760
def reveal_locals(self, type_map: dict[str, Type | None], context: Context) -> None:
17551761
# To ensure that the output is predictable on Python < 3.6,

0 commit comments

Comments
 (0)