Skip to content

Recalculate metaclass in checker.py #13569

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

Closed
wants to merge 1 commit into from

Conversation

sobolevn
Copy link
Member

See #13565 (comment) for motivation.
I tried hard to come up with a test for this, but I was not successful.
Suggestions are welcome.

Copy link
Member Author

@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.

Some thoughts:

  1. It slow downs all regular classes without metaclass
  2. It does not solve all our problems. I see a possible case where metaclass is set to not accurate one because of import cycle

Another idea: maybe we can refactor .metaclass_type to be a @property?

@github-actions
Copy link
Contributor

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

@sobolevn
Copy link
Member Author

No, this is wrong. The problem with PlaceholderNode / missing metaclass is that defn.info.declared_metaclass = inst is not set. There's no point in recalculating metaclass_type without declared_metaclass

@sobolevn sobolevn closed this Aug 31, 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.

1 participant