From 004a2f9249dcae31a91ebfab043aa4fce99e0df5 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Dec 2024 10:50:28 +0100 Subject: [PATCH 1/4] Address xlsx2csv deprecation warning --- py-polars/polars/io/spreadsheet/functions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/py-polars/polars/io/spreadsheet/functions.py b/py-polars/polars/io/spreadsheet/functions.py index 9b22df604242..ecce10d34d72 100644 --- a/py-polars/polars/io/spreadsheet/functions.py +++ b/py-polars/polars/io/spreadsheet/functions.py @@ -1,6 +1,7 @@ from __future__ import annotations import re +import warnings from collections.abc import Sequence from datetime import time from io import BufferedReader, BytesIO, StringIO, TextIOWrapper @@ -1010,7 +1011,12 @@ def _read_spreadsheet_xlsx2csv( """Use the 'xlsx2csv' library to read data from the given worksheet.""" csv_buffer = StringIO() - parser.convert(outfile=csv_buffer, sheetname=sheet_name) + with warnings.catch_warnings(): + # xlsx2csv version 0.8.4 throws a DeprecationWarning in Python 3.13 + # https://github.com/dilshod/xlsx2csv/pull/287 + warnings.filterwarnings("ignore", category=DeprecationWarning) + parser.convert(outfile=csv_buffer, sheetname=sheet_name) + read_options.setdefault("truncate_ragged_lines", True) if columns: read_options["columns"] = columns From fb00ef873ef54bb6308230bac6511572f947b63c Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Dec 2024 11:00:18 +0100 Subject: [PATCH 2/4] Temporarily suppress database warning --- py-polars/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 4ae5f136c7df..9e9021017cdc 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -251,6 +251,9 @@ filterwarnings = [ # TODO: Excel tests lead to unclosed file warnings # https://github.com/pola-rs/polars/issues/14466 "ignore:unclosed file.*:ResourceWarning", + # TODO: Database tests lead to unclosed database warnings + # https://github.com/pola-rs/polars/issues/20296 + "ignore:unclosed database.*:ResourceWarning", # Ignore invalid warnings when running earlier versions of SQLAlchemy (we # know they are invalid because our standard tests run the latest version) "ignore:Deprecated API features detected.*:DeprecationWarning", From 10b3da7eeb9959fdd78f65b26f4525a017ce9006 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Dec 2024 11:33:57 +0100 Subject: [PATCH 3/4] Fix styling docs --- docs/source/src/python/user-guide/misc/styling.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/src/python/user-guide/misc/styling.py b/docs/source/src/python/user-guide/misc/styling.py index f9ee8b8f708d..e001de49dd29 100644 --- a/docs/source/src/python/user-guide/misc/styling.py +++ b/docs/source/src/python/user-guide/misc/styling.py @@ -1,3 +1,13 @@ +# --8<-- [start:setup] +import warnings + +# great-tables throws a Deprecation warning in `as_raw_html` under Python 3.13 +# https://github.com/posit-dev/great-tables/pull/563 +warnings.filterwarnings( + "ignore", "'count' is passed as positional argument", category=DeprecationWarning +) +# --8<-- [end:setup] + # --8<-- [start:dataframe] import polars as pl import polars.selectors as cs From 057badfc64cbd9e8bee4811f19e5f17b2e9e5147 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Dec 2024 11:44:07 +0100 Subject: [PATCH 4/4] Skip numba --- docs/source/requirements.txt | 2 +- py-polars/requirements-dev.txt | 1 - py-polars/tests/docs/test_user_guide.py | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt index 5d7b9089b65f..25e87aeb64ec 100644 --- a/docs/source/requirements.txt +++ b/docs/source/requirements.txt @@ -6,7 +6,7 @@ hvplot matplotlib seaborn plotly -numba +numba >= 0.54; python_version < '3.13' # numba does not support Python 3.13 numpy mkdocs-material==9.5.27 diff --git a/py-polars/requirements-dev.txt b/py-polars/requirements-dev.txt index f38a27bf5462..7fb358bced22 100644 --- a/py-polars/requirements-dev.txt +++ b/py-polars/requirements-dev.txt @@ -21,7 +21,6 @@ numba >= 0.54; python_version < '3.13' # Numba can lag Python releases pandas pyarrow pydantic>=2.0.0 -numba # Datetime / time zones tzdata; platform_system == 'Windows' # Database diff --git a/py-polars/tests/docs/test_user_guide.py b/py-polars/tests/docs/test_user_guide.py index 69586f002e8d..98657c5ad89d 100644 --- a/py-polars/tests/docs/test_user_guide.py +++ b/py-polars/tests/docs/test_user_guide.py @@ -2,6 +2,7 @@ import os import runpy +import sys from collections.abc import Iterator from pathlib import Path @@ -19,6 +20,10 @@ # Skip visualization snippets snippet_paths = [p for p in snippet_paths if "visualization" not in str(p)] +# Skip UDF section on Python 3.13 as numba does not support it yet +if sys.version_info >= (3, 13): + snippet_paths = [p for p in snippet_paths if "user-defined-functions" not in str(p)] + @pytest.fixture(scope="module") def _change_test_dir() -> Iterator[None]: