Skip to content

Commit 36648d6

Browse files
google-labs-jules[bot]tswast
authored andcommitted
chore: fix pytest crash on pandas 3.0 due to missing SettingWithCopyWarning
The `SettingWithCopyWarning` has been removed in pandas 3.0. Having it in `pytest.ini`'s `filterwarnings` caused pytest to crash on startup when resolving the warning class. This change moves the suppression to `conftest.py` where it is applied conditionally only if the warning class exists.
1 parent dbb0339 commit 36648d6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414

1515
from __future__ import annotations
1616

17+
import warnings
18+
1719
import numpy as np
1820
import pandas as pd
1921
import pyarrow as pa
2022
import pytest
2123

2224
import bigframes._config
2325

26+
# Make sure SettingWithCopyWarning is ignored if it exists.
27+
# It was removed in pandas 3.0.
28+
if hasattr(pd.errors, "SettingWithCopyWarning"):
29+
warnings.simplefilter("ignore", pd.errors.SettingWithCopyWarning)
30+
2431

2532
@pytest.fixture(scope="session")
2633
def polars_session_or_bpd():

pytest.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[pytest]
22
doctest_optionflags = NORMALIZE_WHITESPACE
3-
filterwarnings =
4-
ignore::pandas.errors.SettingWithCopyWarning
53
addopts = "--import-mode=importlib"

0 commit comments

Comments
 (0)