From e5a7a6924bb88a4c600d2602b1a40dbf9370f1e3 Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Sun, 7 May 2023 14:08:26 -0400 Subject: [PATCH] upgrade SQLAlchemy and pyright --- pandas-stubs/io/sql.pyi | 7 ++++++- pyproject.toml | 5 +++-- tests/test_io.py | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index df29721f8..09af416e3 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -13,6 +13,7 @@ from typing import ( from pandas.core.base import PandasObject from pandas.core.frame import DataFrame import sqlalchemy.engine +from sqlalchemy.orm import FromStatement import sqlalchemy.sql.expression from typing_extensions import TypeAlias @@ -26,7 +27,11 @@ from pandas._typing import ( _SQLConnection: TypeAlias = str | sqlalchemy.engine.Connectable | sqlite3.Connection _SQLStatement: TypeAlias = ( - str | sqlalchemy.sql.expression.Selectable | sqlalchemy.sql.expression.TextClause + str + | sqlalchemy.sql.expression.Selectable + | sqlalchemy.sql.expression.TextClause + | sqlalchemy.sql.Select + | FromStatement ) @overload diff --git a/pyproject.toml b/pyproject.toml index 09a80ba93..9c0cb7ed9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ types-pytz = ">= 2022.1.1" mypy = "1.2.0" pyarrow = ">=10.0.1" pytest = ">=7.1.2" -pyright = ">= 1.1.305" +pyright = ">= 1.1.306" poethepoet = ">=0.16.5" loguru = ">=0.6.0" pandas = "2.0.1" @@ -60,7 +60,7 @@ xarray = ">=22.6.0" tabulate = ">=0.8.10" jinja2 = "^3.1" scipy = ">=1.9.1" -SQLAlchemy = "<=1.4.45" +SQLAlchemy = ">=2.0.12" types-python-dateutil = ">=2.8.19" [build-system] @@ -195,6 +195,7 @@ reportUnusedVariable = false reportPrivateUsage = false # enable optional checks reportMissingModuleSource = true +useLibraryCodeForTypes = false [tool.codespell] ignore-words-list = "indext, mose, sav, ser" diff --git a/tests/test_io.py b/tests/test_io.py index 1a5b3c05a..24ebce23d 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1095,6 +1095,7 @@ def test_read_sql_via_sqlalchemy_connection(): assert_type(read_sql("select * from test", con=conn), DataFrame), DataFrame, ) + engine.dispose() def test_read_sql_via_sqlalchemy_engine(): @@ -1107,6 +1108,7 @@ def test_read_sql_via_sqlalchemy_engine(): assert_type(read_sql("select * from test", con=engine), DataFrame), DataFrame, ) + engine.dispose() def test_read_sql_generator(): @@ -1218,6 +1220,7 @@ def test_sqlalchemy_text() -> None: assert_type(read_sql(sql_select, con=conn), DataFrame), DataFrame, ) + engine.dispose() def test_read_sql_dtype() -> None: