Skip to content

Fix #18423 - reveal_type not run in "unreachable" branches #18424

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,13 @@ def invalid_signature_for_special_method(

def reveal_type(self, typ: Type, context: Context) -> None:
visitor = TypeStrVisitor(options=self.options)
self.note(f'Revealed type is "{typ.accept(visitor)}"', context)
proper_type = get_proper_type(typ) # Resolve any type aliases or partial types

# Check if the type is UninhabitedType (unreachable code)
if isinstance(proper_type, UninhabitedType):
self.note('Revealed type is "Never"', context)
else:
self.note(f'Revealed type is "{proper_type.accept(visitor)}"', context)

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