Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(python): Prepare test suite for Python 3.13 support #20297

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions docs/source/src/python/user-guide/misc/styling.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion py-polars/polars/io/spreadsheet/functions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions py-polars/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion py-polars/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/docs/test_user_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import runpy
import sys
from collections.abc import Iterator
from pathlib import Path

Expand All @@ -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]:
Expand Down
Loading