Skip to content

Commit 829ae73

Browse files
authored
CLN: Remove 3rd party warning filters (#50674)
* CLN: Remove 3rd party warning filers * Move 3rd party warnings to pyproject.toml, some comments * Move 3rd party warnings to pyproject.toml, some comments
1 parent 9991d5e commit 829ae73

18 files changed

+71
-215
lines changed

pandas/io/parquet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ def write(
285285
**kwargs,
286286
) -> None:
287287
self.validate_dataframe(df)
288-
# thriftpy/protocol/compact.py:339:
289-
# DeprecationWarning: tostring() is deprecated.
290-
# Use tobytes() instead.
291288

292289
if "partition_on" in kwargs and partition_cols is not None:
293290
raise ValueError(

pandas/tests/frame/test_unary.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def test_pos_object(self, df):
114114
[
115115
pytest.param(
116116
pd.DataFrame({"a": ["a", "b"]}),
117-
marks=[pytest.mark.filterwarnings("ignore")],
117+
# filterwarnings removable once min numpy version is 1.25
118+
marks=[
119+
pytest.mark.filterwarnings("ignore:Applying:DeprecationWarning")
120+
],
118121
),
119122
],
120123
)

pandas/tests/io/__init__.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +0,0 @@
1-
import pytest
2-
3-
pytestmark = [
4-
# fastparquet
5-
pytest.mark.filterwarnings(
6-
"ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning"
7-
),
8-
pytest.mark.filterwarnings(
9-
r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning"
10-
),
11-
# xlrd
12-
pytest.mark.filterwarnings(
13-
"ignore:This method will be removed in future versions:DeprecationWarning"
14-
),
15-
pytest.mark.filterwarnings(
16-
"ignore:This method will be removed in future versions. "
17-
r"Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead."
18-
":PendingDeprecationWarning"
19-
),
20-
]

pandas/tests/io/excel/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
import pytest
2-
3-
pytestmark = [
4-
pytest.mark.filterwarnings(
5-
# Looks like tree.getiterator is deprecated in favor of tree.iter
6-
"ignore:This method will be removed in future versions:"
7-
"PendingDeprecationWarning"
8-
),
9-
pytest.mark.filterwarnings(
10-
"ignore:This method will be removed in future versions:DeprecationWarning"
11-
),
12-
]

pandas/tests/io/excel/test_readers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"openpyxl",
4343
marks=[
4444
td.skip_if_no("openpyxl"),
45-
pytest.mark.filterwarnings("ignore:.*html argument"),
4645
],
4746
),
4847
pytest.param(

pandas/tests/io/pytables/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +0,0 @@
1-
import pytest
2-
3-
pytestmark = [
4-
# pytables https://github.com/PyTables/PyTables/issues/822
5-
pytest.mark.filterwarnings(
6-
"ignore:a closed node found in the registry:UserWarning"
7-
),
8-
pytest.mark.filterwarnings(
9-
r"ignore:`np\.object` is a deprecated alias.*:DeprecationWarning"
10-
),
11-
pytest.mark.filterwarnings(
12-
r"ignore:`np\.bool` is a deprecated alias.*:DeprecationWarning"
13-
),
14-
]

pandas/tests/io/pytables/test_categorical.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
pytestmark = [
1818
pytest.mark.single_cpu,
19-
# pytables https://github.com/PyTables/PyTables/issues/822
20-
pytest.mark.filterwarnings(
21-
"ignore:a closed node found in the registry:UserWarning"
22-
),
2319
]
2420

2521

pandas/tests/io/pytables/test_subclass.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
)
1414

1515
pytest.importorskip("tables")
16-
pytestmark = pytest.mark.filterwarnings(
17-
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
18-
)
1916

2017

2118
class TestHDFStoreSubclass:

pandas/tests/io/sas/test_sas7bdat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def data_test_ix(request, dirpath):
3838

3939

4040
# https://github.com/cython/cython/issues/1720
41-
@pytest.mark.filterwarnings("ignore:can't resolve package:ImportWarning")
4241
class TestSAS7BDAT:
4342
@pytest.mark.slow
4443
def test_from_file(self, dirpath, data_test_ix):

pandas/tests/io/test_common.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __fspath__(self):
5050

5151

5252
# https://github.com/cython/cython/issues/1720
53-
@pytest.mark.filterwarnings("ignore:can't resolve package:ImportWarning")
5453
class TestCommonIOCapabilities:
5554
data1 = """index,A,B,C,D
5655
foo,2,3,4,5
@@ -317,9 +316,6 @@ def test_read_expands_user_home_dir(
317316
),
318317
],
319318
)
320-
@pytest.mark.filterwarnings( # pytables np.object_ usage
321-
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
322-
)
323319
def test_read_fspath_all(self, reader, module, path, datapath):
324320
pytest.importorskip(module)
325321
path = datapath(*path)
@@ -372,9 +368,6 @@ def test_write_fspath_all(self, writer_name, writer_kwargs, module):
372368
expected = f_path.read()
373369
assert result == expected
374370

375-
@pytest.mark.filterwarnings( # pytables np.object_ usage
376-
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
377-
)
378371
def test_write_fspath_hdf5(self):
379372
# Same test as write_fspath_all, except HDF5 files aren't
380373
# necessarily byte-for-byte identical for a given dataframe, so we'll

pandas/tests/io/test_parquet.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from io import BytesIO
44
import os
55
import pathlib
6-
from warnings import (
7-
catch_warnings,
8-
filterwarnings,
9-
)
6+
from warnings import catch_warnings
107

118
import numpy as np
129
import pytest
@@ -40,13 +37,7 @@
4037
_HAVE_PYARROW = False
4138

4239
try:
43-
with catch_warnings():
44-
# `np.bool` is a deprecated alias...
45-
filterwarnings("ignore", "`np.bool`", category=DeprecationWarning)
46-
# accessing pd.Int64Index in pd namespace
47-
filterwarnings("ignore", ".*Int64Index.*", category=FutureWarning)
48-
49-
import fastparquet
40+
import fastparquet
5041

5142
_HAVE_FASTPARQUET = True
5243
except ImportError:

pandas/tests/io/test_pickle.py

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
import shutil
2525
import tarfile
2626
import uuid
27-
from warnings import (
28-
catch_warnings,
29-
simplefilter,
30-
)
27+
from warnings import catch_warnings
3128
import zipfile
3229

3330
import numpy as np
@@ -132,49 +129,46 @@ def test_pickles(legacy_pickle):
132129
if not is_platform_little_endian():
133130
pytest.skip("known failure on non-little endian")
134131

135-
with catch_warnings(record=True):
136-
simplefilter("ignore")
137-
138-
data = pd.read_pickle(legacy_pickle)
139-
140-
for typ, dv in data.items():
141-
for dt, result in dv.items():
142-
expected = data[typ][dt]
143-
144-
if typ == "series" and dt == "ts":
145-
# GH 7748
146-
tm.assert_series_equal(result, expected)
147-
assert result.index.freq == expected.index.freq
148-
assert not result.index.freq.normalize
149-
tm.assert_series_equal(result > 0, expected > 0)
150-
151-
# GH 9291
152-
freq = result.index.freq
153-
assert freq + Day(1) == Day(2)
154-
155-
res = freq + pd.Timedelta(hours=1)
156-
assert isinstance(res, pd.Timedelta)
157-
assert res == pd.Timedelta(days=1, hours=1)
158-
159-
res = freq + pd.Timedelta(nanoseconds=1)
160-
assert isinstance(res, pd.Timedelta)
161-
assert res == pd.Timedelta(days=1, nanoseconds=1)
162-
elif typ == "index" and dt == "period":
163-
tm.assert_index_equal(result, expected)
164-
assert isinstance(result.freq, MonthEnd)
165-
assert result.freq == MonthEnd()
166-
assert result.freqstr == "M"
167-
tm.assert_index_equal(result.shift(2), expected.shift(2))
168-
elif typ == "series" and dt in ("dt_tz", "cat"):
169-
tm.assert_series_equal(result, expected)
170-
elif typ == "frame" and dt in (
171-
"dt_mixed_tzs",
172-
"cat_onecol",
173-
"cat_and_float",
174-
):
175-
tm.assert_frame_equal(result, expected)
176-
else:
177-
compare_element(result, expected, typ)
132+
data = pd.read_pickle(legacy_pickle)
133+
134+
for typ, dv in data.items():
135+
for dt, result in dv.items():
136+
expected = data[typ][dt]
137+
138+
if typ == "series" and dt == "ts":
139+
# GH 7748
140+
tm.assert_series_equal(result, expected)
141+
assert result.index.freq == expected.index.freq
142+
assert not result.index.freq.normalize
143+
tm.assert_series_equal(result > 0, expected > 0)
144+
145+
# GH 9291
146+
freq = result.index.freq
147+
assert freq + Day(1) == Day(2)
148+
149+
res = freq + pd.Timedelta(hours=1)
150+
assert isinstance(res, pd.Timedelta)
151+
assert res == pd.Timedelta(days=1, hours=1)
152+
153+
res = freq + pd.Timedelta(nanoseconds=1)
154+
assert isinstance(res, pd.Timedelta)
155+
assert res == pd.Timedelta(days=1, nanoseconds=1)
156+
elif typ == "index" and dt == "period":
157+
tm.assert_index_equal(result, expected)
158+
assert isinstance(result.freq, MonthEnd)
159+
assert result.freq == MonthEnd()
160+
assert result.freqstr == "M"
161+
tm.assert_index_equal(result.shift(2), expected.shift(2))
162+
elif typ == "series" and dt in ("dt_tz", "cat"):
163+
tm.assert_series_equal(result, expected)
164+
elif typ == "frame" and dt in (
165+
"dt_mixed_tzs",
166+
"cat_onecol",
167+
"cat_and_float",
168+
):
169+
tm.assert_frame_equal(result, expected)
170+
else:
171+
compare_element(result, expected, typ)
178172

179173

180174
def python_pickler(obj, path):

pandas/tests/plotting/frame/test_frame_color.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
""" Test cases for DataFrame.plot """
22
import re
3-
import warnings
43

54
import numpy as np
65
import pytest
@@ -18,23 +17,13 @@
1817

1918
@td.skip_if_no_mpl
2019
class TestDataFrameColor(TestPlotBase):
21-
def test_mpl2_color_cycle_str(self):
20+
@pytest.mark.parametrize(
21+
"color", ["C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"]
22+
)
23+
def test_mpl2_color_cycle_str(self, color):
2224
# GH 15516
2325
df = DataFrame(np.random.randn(10, 3), columns=["a", "b", "c"])
24-
colors = ["C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"]
25-
with warnings.catch_warnings(record=True) as w:
26-
warnings.simplefilter("always", "MatplotlibDeprecationWarning")
27-
28-
for color in colors:
29-
_check_plot_works(df.plot, color=color)
30-
31-
# if warning is raised, check that it is the exact problematic one
32-
# GH 36972
33-
if w:
34-
match = "Support for uppercase single-letter colors is deprecated"
35-
warning_message = str(w[0].message)
36-
msg = "MatplotlibDeprecationWarning related to CN colors was raised"
37-
assert match not in warning_message, msg
26+
_check_plot_works(df.plot, color=color)
3827

3928
def test_color_single_series_list(self):
4029
# GH 3486

pandas/tests/test_downstream.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
)
1919
import pandas._testing as tm
2020

21-
# xarray, fsspec, fastparquet all produce these
22-
pytestmark = pytest.mark.filterwarnings(
23-
"ignore:distutils Version classes are deprecated.*:DeprecationWarning"
24-
)
25-
2621

2722
def import_module(name):
2823
# we *only* want to skip if the module is truly not available
@@ -148,12 +143,6 @@ def test_oo_optimized_datetime_index_unpickle():
148143

149144
@pytest.mark.network
150145
@tm.network
151-
# Cython import warning
152-
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
153-
@pytest.mark.filterwarnings(
154-
# patsy needs to update their imports
155-
"ignore:Using or importing the ABCs from 'collections:DeprecationWarning"
156-
)
157146
def test_statsmodels():
158147

159148
statsmodels = import_module("statsmodels") # noqa:F841
@@ -164,8 +153,6 @@ def test_statsmodels():
164153
smf.ols("Lottery ~ Literacy + np.log(Pop1831)", data=df).fit()
165154

166155

167-
# Cython import warning
168-
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
169156
def test_scikit_learn():
170157

171158
sklearn = import_module("sklearn") # noqa:F841
@@ -180,10 +167,8 @@ def test_scikit_learn():
180167
clf.predict(digits.data[-1:])
181168

182169

183-
# Cython import warning and traitlets
184170
@pytest.mark.network
185171
@tm.network
186-
@pytest.mark.filterwarnings("ignore")
187172
def test_seaborn():
188173

189174
seaborn = import_module("seaborn")
@@ -210,8 +195,6 @@ def test_pandas_datareader():
210195
pandas_datareader.DataReader("F", "quandl", "2017-01-01", "2017-02-01")
211196

212197

213-
# Cython import warning
214-
@pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning")
215198
def test_pyarrow(df):
216199

217200
pyarrow = import_module("pyarrow")

pandas/tests/util/test_show_versions.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import os
33
import re
44

5-
import pytest
6-
75
from pandas.util._print_versions import (
86
_get_dependency_info,
97
_get_sys_info,
@@ -12,19 +10,6 @@
1210
import pandas as pd
1311

1412

15-
@pytest.mark.filterwarnings(
16-
# openpyxl
17-
"ignore:defusedxml.lxml is no longer supported:DeprecationWarning"
18-
)
19-
@pytest.mark.filterwarnings(
20-
# html5lib
21-
"ignore:Using or importing the ABCs from:DeprecationWarning"
22-
)
23-
@pytest.mark.filterwarnings(
24-
# https://github.com/pandas-dev/pandas/issues/35252
25-
"ignore:Distutils:UserWarning"
26-
)
27-
@pytest.mark.filterwarnings("ignore:Setuptools is replacing distutils:UserWarning")
2813
def test_show_versions(tmpdir):
2914
# GH39701
3015
as_json = os.path.join(tmpdir, "test_output.json")

pandas/tests/window/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
import pytest
2-
3-
pytestmark = [
4-
# 2021-02-01 needed until numba updates their usage
5-
pytest.mark.filterwarnings(
6-
r"ignore:`np\.int` is a deprecated alias:DeprecationWarning"
7-
),
8-
]

0 commit comments

Comments
 (0)