Skip to content

Recalculate metaclass in checker.py#13569

Closed
sobolevn wants to merge 1 commit into
python:masterfrom
sobolevn:recalc-metaclass
Closed

Recalculate metaclass in checker.py#13569
sobolevn wants to merge 1 commit into
python:masterfrom
sobolevn:recalc-metaclass

Conversation

@sobolevn

Copy link
Copy Markdown
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.

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Contributor

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

@sobolevn

Copy link
Copy Markdown
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