KEMBAR78
Fix type context for assert_type() by JelleZijlstra · Pull Request #12612 · python/mypy · GitHub
Skip to content

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