Skip to content

Make ClassDef.metaclass an Expression instead of str #3847

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
elazarg opened this issue Aug 19, 2017 · 2 comments
Closed

Make ClassDef.metaclass an Expression instead of str #3847

elazarg opened this issue Aug 19, 2017 · 2 comments
Labels
priority-1-normal refactoring Changing mypy's internals

Comments

@elazarg
Copy link
Contributor

elazarg commented Aug 19, 2017

Currently the metaclass node is assumed to be a string. This is inconsistent, requires workarounds such as passing '<error>' from the parser to the semantic analysis phase, and makes it awkward to handle metaclasses that come from different contexts (as in python2).

Making it an Expression works cleanly as far as I can tell, and reduces code duplication.

@ilevkivskyi ilevkivskyi added priority-1-normal refactoring Changing mypy's internals labels Aug 19, 2017
@ilevkivskyi
Copy link
Member

Makes sense to me. But what are arguments in favour of strings, why metaclasses are implemented like this?

@elazarg
Copy link
Contributor Author

elazarg commented Aug 19, 2017

It was introduced in this commit from 2013. I guess making it an expression at that time was too general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-1-normal refactoring Changing mypy's internals
Projects
None yet
Development

No branches or pull requests

2 participants