Skip to content

Commit bc0c1d3

Browse files
authored
CLN: TODOs/noqas/xfails (#44586)
1 parent d5b958a commit bc0c1d3

File tree

17 files changed

+64
-90
lines changed

17 files changed

+64
-90
lines changed

asv_bench/benchmarks/pandas_vb_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
try:
1818
import pandas._testing as tm
1919
except ImportError:
20-
import pandas.util.testing as tm # noqa
20+
import pandas.util.testing as tm # noqa:F401
2121

2222

2323
numeric_dtypes = [

pandas/core/tools/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
nat_strings,
2929
parsing,
3030
)
31-
from pandas._libs.tslibs.parsing import ( # noqa
31+
from pandas._libs.tslibs.parsing import ( # noqa:F401
3232
DateParseError,
3333
format_is_iso,
3434
guess_datetime_format,

pandas/io/parquet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(self):
151151
import pyarrow.parquet
152152

153153
# import utils to register the pyarrow extension types
154-
import pandas.core.arrays._arrow_utils # noqa
154+
import pandas.core.arrays._arrow_utils # noqa:F401
155155

156156
self.api = pyarrow
157157

pandas/tests/arrays/categorical/test_constructors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ def test_constructor(self):
236236
# - when the first is an integer dtype and the second is not
237237
# - when the resulting codes are all -1/NaN
238238
with tm.assert_produces_warning(None):
239-
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"])
239+
Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"])
240240

241241
with tm.assert_produces_warning(None):
242-
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=[3, 4, 5]) # noqa
242+
Categorical([0, 1, 2, 0, 1, 2], categories=[3, 4, 5])
243243

244244
# the next one are from the old docs
245245
with tm.assert_produces_warning(None):
246-
c_old2 = Categorical([0, 1, 2, 0, 1, 2], [1, 2, 3]) # noqa
246+
Categorical([0, 1, 2, 0, 1, 2], [1, 2, 3])
247247
cat = Categorical([1, 2], categories=[1, 2, 3])
248248

249249
# this is a legitimate constructor

pandas/tests/arrays/sparse/test_libsparse.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,10 @@ def test_check_integrity(self):
460460
lengths = []
461461

462462
# 0-length OK
463-
# TODO: index variables are not used...is that right?
464-
index = BlockIndex(0, locs, lengths)
463+
BlockIndex(0, locs, lengths)
465464

466465
# also OK even though empty
467-
index = BlockIndex(1, locs, lengths) # noqa
466+
BlockIndex(1, locs, lengths)
468467

469468
msg = "Block 0 extends beyond end"
470469
with pytest.raises(ValueError, match=msg):

pandas/tests/extension/base/dim2.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import pytest
66

7+
from pandas._libs.missing import is_matching_na
78
from pandas.compat import (
89
IS64,
910
is_platform_windows,
@@ -175,7 +176,7 @@ def test_reductions_2d_axis_none(self, data, method, request):
175176
assert type(err_result) == type(err_expected)
176177
return
177178

178-
assert result == expected # TODO: or matching NA
179+
assert is_matching_na(result, expected) or result == expected
179180

180181
@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
181182
def test_reductions_2d_axis0(self, data, method, request):
@@ -254,8 +255,5 @@ def test_reductions_2d_axis1(self, data, method, request):
254255
# not necessarily type/dtype-preserving, so weaker assertions
255256
assert result.shape == (1,)
256257
expected_scalar = getattr(data, method)()
257-
if pd.isna(result[0]):
258-
# TODO: require matching NA
259-
assert pd.isna(expected_scalar), expected_scalar
260-
else:
261-
assert result[0] == expected_scalar
258+
res = result[0]
259+
assert is_matching_na(res, expected_scalar) or res == expected_scalar

pandas/tests/groupby/aggregate/test_aggregate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def test_agg_must_agg(df):
5757

5858

5959
def test_agg_ser_multi_key(df):
60-
# TODO(wesm): unused
61-
ser = df.C # noqa
6260

6361
f = lambda x: x.sum()
6462
results = df.C.groupby([df.A, df.B]).aggregate(f)

pandas/tests/indexing/test_coercion.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ def test_where_index_datetime(self, fill_val):
780780

781781
self._assert_where_conversion(obj, cond, values, exp, exp_dtype)
782782

783-
@pytest.mark.xfail(reason="GH 22839: do not ignore timezone, must be object")
784783
def test_where_index_datetime64tz(self):
785784
fill_val = pd.Timestamp("2012-01-01", tz="US/Eastern")
786785
exp_dtype = object
@@ -795,9 +794,9 @@ def test_where_index_datetime64tz(self):
795794
assert obj.dtype == "datetime64[ns]"
796795
cond = pd.Index([True, False, True, False])
797796

798-
msg = "Index\\(\\.\\.\\.\\) must be called with a collection of some kind"
799-
with pytest.raises(TypeError, match=msg):
800-
obj.where(cond, fill_val)
797+
res = obj.where(cond, fill_val)
798+
expected = pd.Index([obj[0], fill_val, obj[2], fill_val], dtype=object)
799+
tm.assert_index_equal(res, expected)
801800

802801
values = pd.Index(pd.date_range(fill_val, periods=4))
803802
exp = pd.Index(

pandas/tests/io/pytables/test_append.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,7 @@ def test_append_to_multiple_dropna(setup_path):
896896
tm.assert_index_equal(store.select("df1").index, store.select("df2").index)
897897

898898

899-
@pytest.mark.xfail(
900-
run=False, reason="append_to_multiple_dropna_false is not raising as failed"
901-
)
899+
@pytest.mark.xfail(reason="append_to_multiple_dropna_false is not raising as failed")
902900
def test_append_to_multiple_dropna_false(setup_path):
903901
df1 = tm.makeTimeDataFrame()
904902
df2 = tm.makeTimeDataFrame().rename(columns="{}_2".format)

pandas/tests/io/pytables/test_select.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_select_dtypes(setup_path):
265265
expected = df[df["A"] > 0]
266266

267267
store.append("df", df, data_columns=True)
268-
np_zero = np.float64(0) # noqa
268+
np_zero = np.float64(0) # noqa:F841
269269
result = store.select("df", where=["A>np_zero"])
270270
tm.assert_frame_equal(expected, result)
271271

@@ -683,17 +683,17 @@ def test_frame_select_complex2(setup_path):
683683
expected = read_hdf(hh, "df", where="l1=[2, 3, 4]")
684684

685685
# scope with list like
686-
l = selection.index.tolist() # noqa
686+
l0 = selection.index.tolist() # noqa:F841
687687
store = HDFStore(hh)
688-
result = store.select("df", where="l1=l")
688+
result = store.select("df", where="l1=l0")
689689
tm.assert_frame_equal(result, expected)
690690
store.close()
691691

692-
result = read_hdf(hh, "df", where="l1=l")
692+
result = read_hdf(hh, "df", where="l1=l0")
693693
tm.assert_frame_equal(result, expected)
694694

695695
# index
696-
index = selection.index # noqa
696+
index = selection.index # noqa:F841
697697
result = read_hdf(hh, "df", where="l1=index")
698698
tm.assert_frame_equal(result, expected)
699699

@@ -928,7 +928,7 @@ def test_query_compare_column_type(setup_path):
928928
with ensure_clean_store(setup_path) as store:
929929
store.append("test", df, format="table", data_columns=True)
930930

931-
ts = Timestamp("2014-01-01") # noqa
931+
ts = Timestamp("2014-01-01") # noqa:F841
932932
result = store.select("test", where="real_date > ts")
933933
expected = df.loc[[1], :]
934934
tm.assert_frame_equal(expected, result)

0 commit comments

Comments
 (0)