Open
Description
Scenario that works as expected:
test_db.py
:
from sqlalchemy import String
from sqlalchemy import Column
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = "user"
name = Column(String)
def __init__(self, *, name: str):
self.name = name
Command:
pipenv run mypy --follow-imports=skip test_db.py
Result:
Everything passes, yay! 🎉
Failure scenario:
test_db.py
:
from sqlalchemy import String
from sqlalchemy import Column
from base_file import Base
class User(Base):
__tablename__ = "user"
name = Column(String)
def __init__(self, *, name: str):
self.name = name
base_file.py
:
Base = declarative_base()
Command plus output:
pipenv run mypy --follow-imports=skip test_db.py
test_db.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "Column[String]") [assignment]
Versions.
- OS: mac
- Python: 3.10.13
- SQLAlchemy: 1.4.49
- mypy: 1.3
- SQLAlchemy2-stubs: