Storing an instance of sqlalchemy.dialects.postgresql.UUID to a variable and re-using that in the column declarations is seen as NullType.
Expected behavior
Type should be detected as Column[UUID]?
To Reproduce
from typing import Optional
from uuid import UUID
from sqlalchemy import Column
from sqlalchemy.dialects.postgresql import UUID as PostgresUUID
from sqlalchemy.orm import declarative_base
PgUUID = PostgresUUID(as_uuid=True)
Base = declarative_base()
class Foobar(Base):
__tablename__ = "foobar"
works: Optional[UUID] = Column(PostgresUUID(as_uuid=True))
doesnt: Optional[UUID] = Column(PgUUID)
Error
Running with sqlalchemy.ext.mypy.plugin enabled in mypy configs:
$ mypy foobar.py
foobar.py:15: error: Incompatible types in assignment (expression has type "Column[NullType]", variable has type "UUID") [assignment]
Found 1 error in 1 file (checked 1 source file)
Describe the bug
Storing an instance of
sqlalchemy.dialects.postgresql.UUID
to a variable and re-using that in the column declarations is seen asNullType
.Expected behavior
Type should be detected as
Column[UUID]
?To Reproduce
Error
Running with
sqlalchemy.ext.mypy.plugin
enabled inmypy
configs:Versions.
3.9.9
1.4.39
mypy 0.971
0.0.2a25