Skip to content

Commit bdd88b9

Browse files
authored
CI, CLN remove unnecessary noqa statements, add CI check (#36707)
1 parent 469ad52 commit bdd88b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+88
-86
lines changed

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ repos:
4343
entry: python -m scripts.generate_pip_deps_from_conda
4444
files: ^(environment.yml|requirements-dev.txt)$
4545
pass_filenames: false
46+
- repo: https://github.com/asottile/yesqa
47+
rev: v1.2.2
48+
hooks:
49+
- id: yesqa

asv_bench/benchmarks/pandas_vb_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Compatibility import for the testing module
1717
try:
18-
import pandas._testing as tm # noqa
18+
import pandas._testing as tm
1919
except ImportError:
2020
import pandas.util.testing as tm # noqa
2121

asv_bench/benchmarks/tslibs/offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pandas import offsets
1010

1111
try:
12-
import pandas.tseries.holiday # noqa
12+
import pandas.tseries.holiday
1313
except ImportError:
1414
pass
1515

doc/source/conf.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
# built documents.
147147
#
148148
# The short X.Y version.
149-
import pandas # noqa: E402 isort:skip
149+
import pandas # isort:skip
150150

151151
# version = '%s r%s' % (pandas.__version__, svn_version())
152152
version = str(pandas.__version__)
@@ -441,14 +441,14 @@
441441
# Add custom Documenter to handle attributes/methods of an AccessorProperty
442442
# eg pandas.Series.str and pandas.Series.dt (see GH9322)
443443

444-
import sphinx # noqa: E402 isort:skip
445-
from sphinx.util import rpartition # noqa: E402 isort:skip
446-
from sphinx.ext.autodoc import ( # noqa: E402 isort:skip
444+
import sphinx # isort:skip
445+
from sphinx.util import rpartition # isort:skip
446+
from sphinx.ext.autodoc import ( # isort:skip
447447
AttributeDocumenter,
448448
Documenter,
449449
MethodDocumenter,
450450
)
451-
from sphinx.ext.autosummary import Autosummary # noqa: E402 isort:skip
451+
from sphinx.ext.autosummary import Autosummary # isort:skip
452452

453453

454454
class AccessorDocumenter(MethodDocumenter):

pandas/_typing.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
# and use a string literal forward reference to it in subsequent types
2828
# https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles
2929
if TYPE_CHECKING:
30-
from pandas._libs import Period, Timedelta, Timestamp # noqa: F401
30+
from pandas._libs import Period, Timedelta, Timestamp
3131

32-
from pandas.core.dtypes.dtypes import ExtensionDtype # noqa: F401
32+
from pandas.core.dtypes.dtypes import ExtensionDtype
3333

34-
from pandas import Interval # noqa: F401
34+
from pandas import Interval
3535
from pandas.core.arrays.base import ExtensionArray # noqa: F401
36-
from pandas.core.frame import DataFrame # noqa: F401
36+
from pandas.core.frame import DataFrame
3737
from pandas.core.generic import NDFrame # noqa: F401
38-
from pandas.core.indexes.base import Index # noqa: F401
39-
from pandas.core.series import Series # noqa: F401
38+
from pandas.core.indexes.base import Index
39+
from pandas.core.series import Series
4040

4141
# array-like
4242

pandas/api/types/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pandas._libs.lib import infer_dtype
66

7-
from pandas.core.dtypes.api import * # noqa: F403, F401
7+
from pandas.core.dtypes.api import * # noqa: F401, F403
88
from pandas.core.dtypes.concat import union_categoricals
99
from pandas.core.dtypes.dtypes import (
1010
CategoricalDtype,

pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ def ip():
12261226
from IPython.core.interactiveshell import InteractiveShell
12271227

12281228
# GH#35711 make sure sqlite history file handle is not leaked
1229-
from traitlets.config import Config # noqa: F401 isort:skip
1229+
from traitlets.config import Config # isort:skip
12301230

12311231
c = Config()
12321232
c.HistoryManager.hist_file = ":memory:"

pandas/core/arrays/floating.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .masked import BaseMaskedArray, BaseMaskedDtype
3535

3636
if TYPE_CHECKING:
37-
import pyarrow # noqa: F401
37+
import pyarrow
3838

3939

4040
class FloatingDtype(BaseMaskedDtype):
@@ -82,7 +82,7 @@ def __from_arrow__(
8282
"""
8383
Construct FloatingArray from pyarrow Array/ChunkedArray.
8484
"""
85-
import pyarrow # noqa: F811
85+
import pyarrow
8686

8787
from pandas.core.arrays._arrow_utils import pyarrow_array_to_numpy_and_mask
8888

pandas/io/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
if TYPE_CHECKING:
56-
from io import IOBase # noqa: F401
56+
from io import IOBase
5757

5858

5959
def is_url(url) -> bool:

pandas/io/formats/console.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def check_main():
6969
return not hasattr(main, "__file__") or get_option("mode.sim_interactive")
7070

7171
try:
72-
return __IPYTHON__ or check_main() # noqa
72+
return __IPYTHON__ or check_main()
7373
except NameError:
7474
return check_main()
7575

@@ -83,7 +83,7 @@ def in_ipython_frontend():
8383
bool
8484
"""
8585
try:
86-
ip = get_ipython() # noqa
86+
ip = get_ipython()
8787
return "zmq" in str(type(ip)).lower()
8888
except NameError:
8989
pass

pandas/io/formats/info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pandas.io.formats.printing import pprint_thing
1313

1414
if TYPE_CHECKING:
15-
from pandas.core.series import Series # noqa: F401
15+
from pandas.core.series import Series
1616

1717

1818
def _put_str(s: Union[str, Dtype], space: int) -> str:

pandas/io/json/_table_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import pandas.core.common as com
2727

2828
if TYPE_CHECKING:
29-
from pandas.core.indexes.multi import MultiIndex # noqa: F401
29+
from pandas.core.indexes.multi import MultiIndex
3030

3131
loads = json.loads
3232

pandas/io/pytables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from pandas.io.formats.printing import adjoin, pprint_thing
5858

5959
if TYPE_CHECKING:
60-
from tables import Col, File, Node # noqa:F401
60+
from tables import Col, File, Node
6161

6262

6363
# versioning attribute

pandas/io/sas/sasreader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pandas.io.common import get_filepath_or_buffer, stringify_path
1010

1111
if TYPE_CHECKING:
12-
from pandas import DataFrame # noqa: F401
12+
from pandas import DataFrame
1313

1414

1515
# TODO(PY38): replace with Protocol in Python 3.8

pandas/plotting/_matplotlib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from pandas.plotting._matplotlib.tools import table
3030

3131
if TYPE_CHECKING:
32-
from pandas.plotting._matplotlib.core import MPLPlot # noqa: F401
32+
from pandas.plotting._matplotlib.core import MPLPlot
3333

3434
PLOT_CLASSES: Dict[str, Type["MPLPlot"]] = {
3535
"line": LinePlot,

pandas/plotting/_matplotlib/timeseries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
if TYPE_CHECKING:
2727
from matplotlib.axes import Axes
2828

29-
from pandas import Index, Series # noqa:F401
29+
from pandas import Index, Series
3030

3131
# ---------------------------------------------------------------------
3232
# Plotting functions and monkey patches

pandas/plotting/_matplotlib/tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
if TYPE_CHECKING:
1818
from matplotlib.axes import Axes
1919
from matplotlib.axis import Axis
20-
from matplotlib.lines import Line2D # noqa:F401
20+
from matplotlib.lines import Line2D
2121
from matplotlib.table import Table
2222

2323

pandas/tests/arrays/categorical/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_constructor(self):
213213
# - when the first is an integer dtype and the second is not
214214
# - when the resulting codes are all -1/NaN
215215
with tm.assert_produces_warning(None):
216-
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"]) # noqa
216+
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"])
217217

218218
with tm.assert_produces_warning(None):
219219
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=[3, 4, 5]) # noqa

pandas/tests/arrays/categorical/test_repr.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_categorical_repr_timedelta(self):
320320

321321
c = Categorical(idx.append(idx), categories=idx)
322322
exp = """[1 days, 2 days, 3 days, 4 days, 5 days, 1 days, 2 days, 3 days, 4 days, 5 days]
323-
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]""" # noqa
323+
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]"""
324324

325325
assert repr(c) == exp
326326

@@ -347,13 +347,13 @@ def test_categorical_repr_timedelta_ordered(self):
347347
idx = timedelta_range("1 days", periods=5)
348348
c = Categorical(idx, ordered=True)
349349
exp = """[1 days, 2 days, 3 days, 4 days, 5 days]
350-
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]""" # noqa
350+
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]"""
351351

352352
assert repr(c) == exp
353353

354354
c = Categorical(idx.append(idx), categories=idx, ordered=True)
355355
exp = """[1 days, 2 days, 3 days, 4 days, 5 days, 1 days, 2 days, 3 days, 4 days, 5 days]
356-
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]""" # noqa
356+
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]"""
357357

358358
assert repr(c) == exp
359359

pandas/tests/arrays/sparse/test_libsparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def test_check_integrity(self):
452452

453453
# 0-length OK
454454
# TODO: index variables are not used...is that right?
455-
index = BlockIndex(0, locs, lengths) # noqa
455+
index = BlockIndex(0, locs, lengths)
456456

457457
# also OK even though empty
458458
index = BlockIndex(1, locs, lengths) # noqa

pandas/tests/computation/test_eval.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949
for engine in ENGINES
5050
)
51-
) # noqa
51+
)
5252
def engine(request):
5353
return request.param
5454

@@ -1885,7 +1885,7 @@ def test_global_scope(self, engine, parser):
18851885
)
18861886

18871887
def test_no_new_locals(self, engine, parser):
1888-
x = 1 # noqa
1888+
x = 1
18891889
lcls = locals().copy()
18901890
pd.eval("x + 1", local_dict=lcls, engine=engine, parser=parser)
18911891
lcls2 = locals().copy()
@@ -1995,8 +1995,8 @@ def test_bool_ops_fails_on_scalars(lhs, cmp, rhs, engine, parser):
19951995
gen = {int: lambda: np.random.randint(10), float: np.random.randn}
19961996

19971997
mid = gen[lhs]() # noqa
1998-
lhs = gen[lhs]() # noqa
1999-
rhs = gen[rhs]() # noqa
1998+
lhs = gen[lhs]()
1999+
rhs = gen[rhs]()
20002000

20012001
ex1 = f"lhs {cmp} mid {cmp} rhs"
20022002
ex2 = f"lhs {cmp} mid and mid {cmp} rhs"

pandas/tests/dtypes/test_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ def test_nan_to_nat_conversions():
14951495

14961496
@td.skip_if_no_scipy
14971497
@pytest.mark.filterwarnings("ignore::PendingDeprecationWarning")
1498-
def test_is_scipy_sparse(spmatrix): # noqa: F811
1498+
def test_is_scipy_sparse(spmatrix):
14991499
assert is_scipy_sparse(spmatrix([[0, 1]]))
15001500
assert not is_scipy_sparse(np.array([1]))
15011501

pandas/tests/frame/indexing/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ def test_getitem_setitem_float_labels(self):
10911091
cp.iloc[1.0:5] = 0
10921092

10931093
with pytest.raises(TypeError, match=msg):
1094-
result = cp.iloc[1.0:5] == 0 # noqa
1094+
result = cp.iloc[1.0:5] == 0
10951095

10961096
assert result.values.all()
10971097
assert (cp.iloc[0:1] == df.iloc[0:1]).values.all()

pandas/tests/frame/test_block_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_consolidate_inplace(self, float_frame):
7878
def test_values_consolidate(self, float_frame):
7979
float_frame["E"] = 7.0
8080
assert not float_frame._mgr.is_consolidated()
81-
_ = float_frame.values # noqa
81+
_ = float_frame.values
8282
assert float_frame._mgr.is_consolidated()
8383

8484
def test_modify_values(self, float_frame):

pandas/tests/frame/test_query_eval.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,7 @@ def test_chained_cmp_and_in(self):
633633
res = df.query(
634634
"a < b < c and a not in b not in c", engine=engine, parser=parser
635635
)
636-
ind = (
637-
(df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) & ~df.c.isin(df.b)
638-
) # noqa
636+
ind = (df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) & ~df.c.isin(df.b)
639637
expec = df[ind]
640638
tm.assert_frame_equal(res, expec)
641639

pandas/tests/indexes/categorical/test_formats.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_string_categorical_index_repr(self):
1818
expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
1919
'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
2020
'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
21-
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')""" # noqa
21+
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""
2222

2323
assert repr(idx) == expected
2424

@@ -49,7 +49,7 @@ def test_string_categorical_index_repr(self):
4949
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
5050
'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
5151
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
52-
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa
52+
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""
5353

5454
assert repr(idx) == expected
5555

@@ -84,7 +84,7 @@ def test_string_categorical_index_repr(self):
8484
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
8585
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
8686
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
87-
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa
87+
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""
8888

8989
assert repr(idx) == expected
9090

pandas/tests/indexes/multi/test_formats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,5 @@ def test_tuple_width(self, wide_multi_index):
206206
('abc', 10, '2000-01-01 00:33:17', '2000-01-01 00:33:17', ...),
207207
('abc', 10, '2000-01-01 00:33:18', '2000-01-01 00:33:18', ...),
208208
('abc', 10, '2000-01-01 00:33:19', '2000-01-01 00:33:19', ...)],
209-
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'], length=2000)""" # noqa
209+
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'], length=2000)"""
210210
assert result == expected

pandas/tests/indexes/multi/test_sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_unsortedindex():
119119

120120

121121
def test_unsortedindex_doc_examples():
122-
# https://pandas.pydata.org/pandas-docs/stable/advanced.html#sorting-a-multiindex # noqa
122+
# https://pandas.pydata.org/pandas-docs/stable/advanced.html#sorting-a-multiindex
123123
dfm = DataFrame(
124124
{"jim": [0, 0, 1, 1], "joe": ["x", "x", "z", "y"], "jolie": np.random.rand(4)}
125125
)

pandas/tests/indexing/test_callable.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def test_frame_loc_callable(self):
1717
res = df.loc[lambda x: x.A > 2]
1818
tm.assert_frame_equal(res, df.loc[df.A > 2])
1919

20-
res = df.loc[lambda x: x.A > 2] # noqa: E231
21-
tm.assert_frame_equal(res, df.loc[df.A > 2]) # noqa: E231
20+
res = df.loc[lambda x: x.A > 2]
21+
tm.assert_frame_equal(res, df.loc[df.A > 2])
2222

23-
res = df.loc[lambda x: x.A > 2] # noqa: E231
24-
tm.assert_frame_equal(res, df.loc[df.A > 2]) # noqa: E231
23+
res = df.loc[lambda x: x.A > 2]
24+
tm.assert_frame_equal(res, df.loc[df.A > 2])
2525

2626
res = df.loc[lambda x: x.B == "b", :]
2727
tm.assert_frame_equal(res, df.loc[df.B == "b", :])
@@ -90,8 +90,8 @@ def test_frame_loc_callable_labels(self):
9090
res = df.loc[lambda x: ["A", "C"]]
9191
tm.assert_frame_equal(res, df.loc[["A", "C"]])
9292

93-
res = df.loc[lambda x: ["A", "C"]] # noqa: E231
94-
tm.assert_frame_equal(res, df.loc[["A", "C"]]) # noqa: E231
93+
res = df.loc[lambda x: ["A", "C"]]
94+
tm.assert_frame_equal(res, df.loc[["A", "C"]])
9595

9696
res = df.loc[lambda x: ["A", "C"], :]
9797
tm.assert_frame_equal(res, df.loc[["A", "C"], :])

pandas/tests/io/formats/test_style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pandas._testing as tm
1313

1414
jinja2 = pytest.importorskip("jinja2")
15-
from pandas.io.formats.style import Styler, _get_level_lengths # noqa # isort:skip
15+
from pandas.io.formats.style import Styler, _get_level_lengths # isort:skip
1616

1717

1818
class TestStyler:

0 commit comments

Comments
 (0)