-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
"Invalid base class" when base class is returned from a function. #4284
Comments
This is explicitly listed in the wiki as unsupported see https://github.com/python/mypy/wiki/Unsupported-Python-Features. It would be challenging to correctly type your example as of now. |
I don't really expect mypy to be able to do any meaningful type checking, but it would be convenient if it would at least understand that |
Understood, mypy uses several passes, and currently the return type of c() is not available at the moment it needs the type for the base class of D. Base classes are required to be known in an earlier pass because knowing the bases of a class (actually, its full MRO) is needed to type-check other code. Your best work-around in this case os to put |
If 'base class is returned from a function', mypy won't treat it propery. This is reported and commented by collaborator as *Unsupported feature* python/mypy#4284
Otherwise mypy complains 'error: Invalid base class' for this code: ,---- | class Block(Base): | __tablename__ = "blocks" | ... `---- see python/mypy#4284
Mypy does not support a base class that is returned from a function. See https://github.com/python/mypy/wiki/Unsupported-Python-Features for details Similar reported cases: python/mypy#4284 python/mypy#6372
Mypy does not support a base class that is returned from a function. See https://github.com/python/mypy/wiki/Unsupported-Python-Features for details Similar reported cases: python/mypy#4284 python/mypy#6372
I also tried returning
typing.Any
, which seemed like it might work based on #2477 (comment) .The text was updated successfully, but these errors were encountered: