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

Unhelpful error "Invalid base class mypy(error)" #6372

Closed
vivaldus opened this issue Feb 11, 2019 · 2 comments
Closed

Unhelpful error "Invalid base class mypy(error)" #6372

vivaldus opened this issue Feb 11, 2019 · 2 comments

Comments

@vivaldus
Copy link

The following sql-entity class was generated by sqlalchemy -- so this is the standard way to create such a class and operate it. However, mypy calls Base here an Invalid base class. But why? No further details are given, I see no such error described in mypy documentation, and googling "Invalid base class" doesn't lead me to any obvious results. I have no way to diagnose the problem.

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()

class SomeClass(Base)
    ....

mypy version 0.660
python version 3.7.2

@emmatyping
Copy link
Collaborator

emmatyping commented Feb 11, 2019

In this case it is because the Base class is dynamic (computed from a function return), therefore mypy cannot use it for static analysis.

Also this is a duplicate of #2477 (the issue is tracking a better error message and add support for dynamic base classes #2477 (comment)).

@ilevkivskyi
Copy link
Member

@vivaldus As I mentioned in my closing notice for #2477 you should use SQLAlchemy plugin. The error message is now tracked in #4030.

HiromuHota pushed a commit to HiromuHota/fonduer that referenced this issue Aug 14, 2019
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
lukehsiao pushed a commit to HazyResearch/fonduer that referenced this issue Aug 16, 2019
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
itissid added a commit to itissid/Drop-PoT that referenced this issue Sep 12, 2023
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

No branches or pull requests

3 participants