Skip to content
5 changes: 2 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,8 @@ class Temp(Base):

Session = sqlalchemy.orm.sessionmaker(engine)
with Session() as session:
pd.read_sql(
session.query(Temp.quantity).statement, session.connection()
)
stmt = sqlalchemy.select(Temp.quantity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are modifying the type of stmt so you are not really testing what used to be tested. What is needed is to update the stubs so that this test passes.
Without changing this test, what needs to be done is to update a pyi file.
For that I would recommend you look into what is the new type of stmt with the update of sqlalchemy, you will see that stmt has now an extra possible type UpdateBase and what how that impacts the stubs in pandas-stubs/io/sql.pyi. There you see that the Type Alias _SQLStatement is too restrictive and you need to allow UpdateBase in that TypeAlias too.
Feel free to let me know if something is unclear.

pd.read_sql(stmt, session.connection())


def test_sqlalchemy_text() -> None:
Expand Down