Skip to content

Commit 69415c1

Browse files
committed
chore: remove pandas 3.0 warnings -> instead, disable pandas for 3.14 for now.
1 parent d6c8779 commit 69415c1

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ required-environments = [ # ... but do always resolve for all of them
211211
"python_version >= '3.9' and sys_platform == 'linux' and platform_machine == 'x86_64'",
212212
"python_version >= '3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
213213
]
214-
prerelease = "allow" # for 3.14
214+
prerelease = "if-necessary-or-explicit" # for 3.14
215215

216216
# We just need pytorch for tests, wihtout GPU acceleration. PyPI doesn't host a cpu-only version for Linux, so we have
217217
# to configure the index url for cpu-only pytorch manually
@@ -313,7 +313,6 @@ filterwarnings = [
313313
# Pyspark is throwing these warnings
314314
"ignore:distutils Version classes are deprecated:DeprecationWarning",
315315
"ignore:is_datetime64tz_dtype is deprecated:DeprecationWarning",
316-
"ignore:ChainedAssignmentError.*:FutureWarning"
317316
]
318317

319318
[tool.coverage.run]

tests/conftest.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,63 @@
66
import duckdb
77
import warnings
88
from importlib import import_module
9+
import sys
910

1011
try:
1112
# need to ignore warnings that might be thrown deep inside pandas's import tree (from dateutil in this case)
12-
warnings.simplefilter(action='ignore', category=DeprecationWarning)
13-
pandas = import_module('pandas')
13+
warnings.simplefilter(action="ignore", category=DeprecationWarning)
14+
pandas = import_module("pandas")
1415
warnings.resetwarnings()
1516

16-
pyarrow_dtype = getattr(pandas, 'ArrowDtype', None)
17+
pyarrow_dtype = getattr(pandas, "ArrowDtype", None)
1718
except ImportError:
1819
pandas = None
1920
pyarrow_dtype = None
2021

22+
# Only install mock after we've failed to import pandas for conftest.py
23+
class MockPandas:
24+
def __getattr__(self, name):
25+
pytest.skip("pandas not available", allow_module_level=True)
26+
27+
sys.modules["pandas"] = MockPandas()
28+
sys.modules["pandas.testing"] = MockPandas()
29+
sys.modules["pandas._testing"] = MockPandas()
30+
2131
# Check if pandas has arrow dtypes enabled
22-
try:
23-
from pandas.compat import pa_version_under7p0
32+
if pandas is not None:
33+
try:
34+
from pandas.compat import pa_version_under7p0
2435

25-
pyarrow_dtypes_enabled = not pa_version_under7p0
26-
except ImportError:
36+
pyarrow_dtypes_enabled = not pa_version_under7p0
37+
except (ImportError, AttributeError):
38+
pyarrow_dtypes_enabled = False
39+
else:
2740
pyarrow_dtypes_enabled = False
2841

2942

3043
def import_pandas():
3144
if pandas:
3245
return pandas
3346
else:
34-
pytest.skip("Couldn't import pandas")
47+
pytest.skip("Couldn't import pandas", allow_module_level=True)
3548

3649

3750
# https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
3851
# https://stackoverflow.com/a/47700320
3952
def pytest_addoption(parser):
4053
parser.addoption("--skiplist", action="append", nargs="+", type=str, help="skip listed tests")
4154

55+
@pytest.hookimpl(hookwrapper=True)
56+
def pytest_runtest_call(item):
57+
"""Convert pandas requirement exceptions to skips"""
58+
outcome = yield
59+
try:
60+
outcome.get_result()
61+
except Exception as e:
62+
if "'pandas' is required for this operation but it was not installed" in str(e):
63+
pytest.skip("pandas not available - test requires pandas functionality")
64+
65+
4266

4367
def pytest_collection_modifyitems(config, items):
4468
tests_to_skip = config.getoption("--skiplist")

tests/fast/numpy/test_numpy_new_path.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import duckdb
77
from datetime import timedelta
88
import pytest
9+
import pandas # https://github.com/duckdb/duckdb-python/issues/48
910

1011

1112
class TestScanNumpy(object):

tests/pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
[pytest]
33
filterwarnings =
44
error
5-
# Pandas ChainedAssignmentError warnings for 3.0
6-
ignore:ChainedAssignmentError.*:FutureWarning
75
ignore::UserWarning
86
ignore::DeprecationWarning
97
# Jupyter is throwing DeprecationWarnings

0 commit comments

Comments
 (0)