Skip to content
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

Fix type context for assert_type() #12612

Merged
merged 1 commit into from
Apr 18, 2022

Conversation

JelleZijlstra
Copy link
Member

Noticed in python/typeshed#7655 that it was incorrectly inferring list[Any]
in all cases. This is because I incorrectly put Any as the type context
in the assert_type implementation. Use the current context instead, like
for reveal_type().

Noticed in python/typeshed#7655 that it was incorrectly inferring list[Any]
in all cases. This is because I incorrectly put Any as the type context
in the assert_type implementation. Use the current context instead, like
for reveal_type().
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Good catch. I saw that in the original PR, but it matched cast so I didn't think about it. But of course, type context doesn't matter for cast.

@hauntsaninja hauntsaninja merged commit f501cf6 into python:master Apr 18, 2022
@JelleZijlstra JelleZijlstra deleted the asserttypecontext branch April 18, 2022 01:08
@JelleZijlstra
Copy link
Member Author

Thanks! I'm not 100% convinced cast() shouldn't do the same thing I did in this PR; it might make us better at finding unnecessary casts.

This was referenced Apr 18, 2022
JukkaL pushed a commit that referenced this pull request Apr 20, 2022
Noticed in python/typeshed#7655 that it was incorrectly inferring list[Any]
in all cases. This is because I incorrectly put Any as the type context
in the assert_type implementation. Use the current context instead, like
for reveal_type().
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.

2 participants