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

Mypy can now understand deleted TypeInfo #13481

Merged
merged 3 commits into from
Aug 24, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Aug 22, 2022

We now correctly handle deleted TypeInfo
Closes #13226

This is a new part of mypy for me, so careful review is required.

@github-actions

This comment has been minimized.

mypy/binder.py Outdated
if not isinstance(get_proper_type(type), PartialType):
return type
elif isinstance(expr.node, TypeInfo):
return Instance(
Copy link
Collaborator

@hauntsaninja hauntsaninja Aug 23, 2022

Choose a reason for hiding this comment

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

I'm not sure this is right... The declared type of a TypeInfo should probably be expr.node.calculate_metaclass_type() or something right?

I don't have the best sense of this code either, so not sure how much of a difference this makes though.

I did notice another issue while reviewing this PR: #13483

Copy link
Member Author

@sobolevn sobolevn Aug 23, 2022

Choose a reason for hiding this comment

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

Fair enough, let's use TypeType for this.

(.calculate_metaclass_type always returns None for regular types)

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

@hauntsaninja hauntsaninja merged commit f83835c into python:master Aug 24, 2022
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.

"Trying to read deleted variable" false negative when deleting class
2 participants