Skip to content

Mypy fails with inner class #141

Open
@kasium

Description

@kasium

Describe the bug
If a ORM class is created inside a function, mypy fails. As soon as the class is outside of a function, it works fine

Expected behavior
No error

To Reproduce

from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer

def inner() -> None:
    Base = declarative_base()

    class _DummyTable(Base):
        __tablename__ = "user"
        col1 = Column(Integer, primary_key=True)
    instance = _DummyTable(col1=1)

Error

x.py:13:16: error: Unexpected keyword argument "col1" for "_DummyTable"  [call-arg]
        instance = _DummyTable(col1=1)

Versions.

  • OS: Linux
  • Python: 3.7.1
  • SQLAlchemy: 1.4.22
  • mypy: 0.910
  • SQLAlchemy2-stubs: 0.0.2a6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmypy pluginsomething that has to do with the sqlalchemy mypy plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions