Skip to content

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

Closed

Description

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

Activity

  1. emmatyping commented on Feb 11, 2019

    @emmatyping
    Member

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

  2. ilevkivskyi commented on Feb 11, 2019

    @ilevkivskyi
    Member

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

  3. added a commit that references this issue on Aug 14, 2019
  4. added a commit that references this issue on Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions