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

@JelleZijlstra JelleZijlstra commented Apr 17, 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().

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

@github-actions github-actions bot commented Apr 17, 2022

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

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

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
15 checks passed
@JelleZijlstra JelleZijlstra deleted the asserttypecontext branch Apr 18, 2022
@JelleZijlstra
Copy link
Member Author

@JelleZijlstra JelleZijlstra commented Apr 18, 2022

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.

JukkaL pushed a commit that referenced this issue 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.

None yet

2 participants