-
-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When using scoped_session[Session] with SQLAlchemyFactory, mypy reports a type incompatibility error:
error: Incompatible types in assignment (expression has type "scoped_session[Session]", base class "SQLAlchemyFactory" defined the type as "Session | _SessionMaker[Session] | None") [assignment]
Expected Behavior
scoped_session[Session] should be accepted as a valid session type since it's a SQLAlchemy session wrapper that implements the same interface as Session and is commonly used in applications.
Steps to reproduce
from sqlalchemy.orm import Session, scoped_session, sessionmaker
from sqlalchemy import create_engine
from polyfactory.factories.sqlalchemy_factory import SQLAlchemyFactory, T
engine = create_engine(DB_URL)
global_session = scoped_session(sessionmaker(bind=engine))
class BaseModelFactory(SQLAlchemyFactory[T]):
__is_base_factory__ = True
__session__ = global_session # Type error hereScreenshots
Release Version
2.21.0
adhtruong and AlexPetul
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working