Skip to content

Conversation

@JelleZijlstra
Copy link
Member

Description

Add support for typing.reveal_type (python/cpython#30646) and typing_extensions.reveal_type (python/typing#1055).

Test Plan

Added two test cases.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks!

I guess we also need to sync typeshed for this to work properly with 3.11+ in production,right?


[case testTypingRevealType]
from typing import reveal_type
from typing import reveal_type as show_me_the_type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit: Let's also try rt = reveal_type and rt(1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That actually doesn't work, probably because at the place in semanal where we recognize reveal_type we can't see through assignments yet. Fixing it would probably be a lot more complicated than this PR, so if we think it's worth fixing, we should do it separately. It doesn't seem too important as no user has asked for it so far.

@JelleZijlstra
Copy link
Member Author

Yes, I'll update typeshed at some point too. Thanks for the review! I'll add some additional tests.

@JelleZijlstra JelleZijlstra merged commit 84b9778 into master Feb 3, 2022
@JelleZijlstra JelleZijlstra deleted the revealtype branch February 3, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants