sqlalchemy2-stubs
sqlalchemy2-stubs copied to clipboard
Mypy fails with inner class
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
As far as I can see this is a limitation with the mypy plugin. I'm open to open/search for an issue on their side if it helps