From ecb7d57d28015f939e65019e5dcac1ef6b39a46a Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Wed, 8 Nov 2023 11:22:59 +0100 Subject: [PATCH] Handle dependencies --- py-polars/pyproject.toml | 2 ++ py-polars/requirements-dev.txt | 7 +++- py-polars/tests/unit/io/test_database_read.py | 14 ++++++++ .../tests/unit/io/test_database_write.py | 32 +++++++++++++------ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 7e83b258913cc..7f749d6e46f42 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -215,6 +215,8 @@ filterwarnings = [ # Ignore warnings issued by dependency internals "ignore:.*is_sparse is deprecated.*:FutureWarning", "ignore:FigureCanvasAgg is non-interactive:UserWarning", + "ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated.*:DeprecationWarning", + "ignore:datetime.datetime.utcnow\\(\\) is deprecated.*:DeprecationWarning", ] xfail_strict = true diff --git a/py-polars/requirements-dev.txt b/py-polars/requirements-dev.txt index e5b1f4203d4d7..d5950b552d05f 100644 --- a/py-polars/requirements-dev.txt +++ b/py-polars/requirements-dev.txt @@ -26,11 +26,16 @@ tzdata; platform_system == 'Windows' # Database SQLAlchemy adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows' -connectorx +# TODO: Remove version constraint for connectorx when Python 3.12 is supported: +# https://github.com/sfu-db/connector-x/issues/527 +connectorx; python_version <= '3.11' # Cloud cloudpickle fsspec s3fs[boto3] +# TODO: Unpin and remove aiohttp here when 3.9.0 is released: +# https://github.com/aio-libs/aiohttp/issues/7739 +aiohttp==3.9.0b1 # Spreadsheet ezodf lxml diff --git a/py-polars/tests/unit/io/test_database_read.py b/py-polars/tests/unit/io/test_database_read.py index 824ffb989fd2e..755e36bcb8a40 100644 --- a/py-polars/tests/unit/io/test_database_read.py +++ b/py-polars/tests/unit/io/test_database_read.py @@ -34,6 +34,12 @@ def adbc_sqlite_connect(*args: Any, **kwargs: Any) -> Any: def create_temp_sqlite_db(test_db: str) -> None: Path(test_db).unlink(missing_ok=True) + def convert_date(val): + """Convert ISO 8601 date to datetime.date object.""" + return date.fromisoformat(val.decode()) + + sqlite3.register_converter("date", convert_date) + # NOTE: at the time of writing adcb/connectorx have weak SQLite support (poor or # no bool/date/datetime dtypes, for example) and there is a bug in connectorx that # causes float rounding < py 3.11, hence we are only testing/storing simple values @@ -183,6 +189,10 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any: # noqa: D102 schema_overrides={"id": pl.UInt8}, ), id="uri: connectorx", + marks=pytest.mark.skipif( + sys.version_info > (3, 11), + reason="connectorx cannot be installed on Python 3.12 yet.", + ), ), pytest.param( *DatabaseReadTestParams( @@ -584,6 +594,10 @@ def test_read_database_exceptions( read_database(**params) +@pytest.mark.skipif( + sys.version_info > (3, 11), + reason="connectorx cannot be installed on Python 3.12 yet.", +) @pytest.mark.parametrize( "uri", [ diff --git a/py-polars/tests/unit/io/test_database_write.py b/py-polars/tests/unit/io/test_database_write.py index 8a4227fe564c4..4b19c1c4bb2dd 100644 --- a/py-polars/tests/unit/io/test_database_write.py +++ b/py-polars/tests/unit/io/test_database_write.py @@ -23,12 +23,16 @@ def adbc_sqlite_driver_version(*args: Any, **kwargs: Any) -> str: return "n/a" -@pytest.mark.write_disk() -@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"]) +@pytest.mark.skipif( + sys.version_info > (3, 11), + reason="connectorx cannot be installed on Python 3.12 yet.", +) @pytest.mark.skipif( sys.version_info < (3, 9) or sys.platform == "win32", reason="adbc_driver_sqlite not available below Python 3.9 / on Windows", ) +@pytest.mark.write_disk() +@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"]) def test_write_database_create(engine: DbWriteEngine, tmp_path: Path) -> None: df = pl.DataFrame( { @@ -51,12 +55,16 @@ def test_write_database_create(engine: DbWriteEngine, tmp_path: Path) -> None: assert_frame_equal(result, df) -@pytest.mark.write_disk() -@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"]) +@pytest.mark.skipif( + sys.version_info > (3, 11), + reason="connectorx cannot be installed on Python 3.12 yet.", +) @pytest.mark.skipif( sys.version_info < (3, 9) or sys.platform == "win32", reason="adbc_driver_sqlite not available below Python 3.9 / on Windows", ) +@pytest.mark.write_disk() +@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"]) def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None: df = pl.DataFrame( { @@ -96,6 +104,10 @@ def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None: assert_frame_equal(result, pl.concat([df, df])) +@pytest.mark.skipif( + sys.version_info < (3, 9) or sys.platform == "win32", + reason="adbc_driver_sqlite not available below Python 3.9 / on Windows", +) @pytest.mark.write_disk() @pytest.mark.parametrize( "engine", @@ -106,13 +118,15 @@ def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None: reason="ADBC SQLite driver has a bug with quoted/qualified table names", ), ), - "sqlalchemy", + pytest.param( + "sqlalchemy", + marks=pytest.mark.skipif( + sys.version_info > (3, 11), + reason="connectorx cannot be installed on Python 3.12 yet.", + ), + ), ], ) -@pytest.mark.skipif( - sys.version_info < (3, 9) or sys.platform == "win32", - reason="adbc_driver_sqlite not available below Python 3.9 / on Windows", -) def test_write_database_create_quoted_tablename( engine: DbWriteEngine, tmp_path: Path ) -> None: