Skip to content

CI, CLN remove unnecessary noqa statements, add CI check #36707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ repos:
entry: python -m scripts.generate_pip_deps_from_conda
files: ^(environment.yml|requirements-dev.txt)$
pass_filenames: false
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
hooks:
- id: yesqa
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/pandas_vb_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Compatibility import for the testing module
try:
import pandas._testing as tm # noqa
import pandas._testing as tm
except ImportError:
import pandas.util.testing as tm # noqa

Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/tslibs/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandas import offsets

try:
import pandas.tseries.holiday # noqa
import pandas.tseries.holiday
except ImportError:
pass

Expand Down
10 changes: 5 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
# built documents.
#
# The short X.Y version.
import pandas # noqa: E402 isort:skip
import pandas # isort:skip

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

import sphinx # noqa: E402 isort:skip
from sphinx.util import rpartition # noqa: E402 isort:skip
from sphinx.ext.autodoc import ( # noqa: E402 isort:skip
import sphinx # isort:skip
from sphinx.util import rpartition # isort:skip
from sphinx.ext.autodoc import ( # isort:skip
AttributeDocumenter,
Documenter,
MethodDocumenter,
)
from sphinx.ext.autosummary import Autosummary # noqa: E402 isort:skip
from sphinx.ext.autosummary import Autosummary # isort:skip


class AccessorDocumenter(MethodDocumenter):
Expand Down
12 changes: 6 additions & 6 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
# and use a string literal forward reference to it in subsequent types
# https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles
if TYPE_CHECKING:
from pandas._libs import Period, Timedelta, Timestamp # noqa: F401
from pandas._libs import Period, Timedelta, Timestamp

from pandas.core.dtypes.dtypes import ExtensionDtype # noqa: F401
from pandas.core.dtypes.dtypes import ExtensionDtype

from pandas import Interval # noqa: F401
from pandas import Interval
from pandas.core.arrays.base import ExtensionArray # noqa: F401
from pandas.core.frame import DataFrame # noqa: F401
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame # noqa: F401
from pandas.core.indexes.base import Index # noqa: F401
from pandas.core.series import Series # noqa: F401
from pandas.core.indexes.base import Index
from pandas.core.series import Series

# array-like

Expand Down
2 changes: 1 addition & 1 deletion pandas/api/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pandas._libs.lib import infer_dtype

from pandas.core.dtypes.api import * # noqa: F403, F401
from pandas.core.dtypes.api import * # noqa: F401, F403
from pandas.core.dtypes.concat import union_categoricals
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
Expand Down
2 changes: 1 addition & 1 deletion pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ def ip():
from IPython.core.interactiveshell import InteractiveShell

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

c = Config()
c.HistoryManager.hist_file = ":memory:"
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/floating.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .masked import BaseMaskedArray, BaseMaskedDtype

if TYPE_CHECKING:
import pyarrow # noqa: F401
import pyarrow


class FloatingDtype(BaseMaskedDtype):
Expand Down Expand Up @@ -82,7 +82,7 @@ def __from_arrow__(
"""
Construct FloatingArray from pyarrow Array/ChunkedArray.
"""
import pyarrow # noqa: F811
import pyarrow

from pandas.core.arrays._arrow_utils import pyarrow_array_to_numpy_and_mask

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@


if TYPE_CHECKING:
from io import IOBase # noqa: F401
from io import IOBase


def is_url(url) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def check_main():
return not hasattr(main, "__file__") or get_option("mode.sim_interactive")

try:
return __IPYTHON__ or check_main() # noqa
return __IPYTHON__ or check_main()
except NameError:
return check_main()

Expand All @@ -83,7 +83,7 @@ def in_ipython_frontend():
bool
"""
try:
ip = get_ipython() # noqa
ip = get_ipython()
return "zmq" in str(type(ip)).lower()
except NameError:
pass
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pandas.io.formats.printing import pprint_thing

if TYPE_CHECKING:
from pandas.core.series import Series # noqa: F401
from pandas.core.series import Series


def _put_str(s: Union[str, Dtype], space: int) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/json/_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pandas.core.common as com

if TYPE_CHECKING:
from pandas.core.indexes.multi import MultiIndex # noqa: F401
from pandas.core.indexes.multi import MultiIndex

loads = json.loads

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from pandas.io.formats.printing import adjoin, pprint_thing

if TYPE_CHECKING:
from tables import Col, File, Node # noqa:F401
from tables import Col, File, Node


# versioning attribute
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/sas/sasreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandas.io.common import get_filepath_or_buffer, stringify_path

if TYPE_CHECKING:
from pandas import DataFrame # noqa: F401
from pandas import DataFrame


# TODO(PY38): replace with Protocol in Python 3.8
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pandas.plotting._matplotlib.tools import table

if TYPE_CHECKING:
from pandas.plotting._matplotlib.core import MPLPlot # noqa: F401
from pandas.plotting._matplotlib.core import MPLPlot

PLOT_CLASSES: Dict[str, Type["MPLPlot"]] = {
"line": LinePlot,
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if TYPE_CHECKING:
from matplotlib.axes import Axes

from pandas import Index, Series # noqa:F401
from pandas import Index, Series

# ---------------------------------------------------------------------
# Plotting functions and monkey patches
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if TYPE_CHECKING:
from matplotlib.axes import Axes
from matplotlib.axis import Axis
from matplotlib.lines import Line2D # noqa:F401
from matplotlib.lines import Line2D
from matplotlib.table import Table


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/categorical/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_constructor(self):
# - when the first is an integer dtype and the second is not
# - when the resulting codes are all -1/NaN
with tm.assert_produces_warning(None):
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"]) # noqa
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=["a", "b", "c"])

with tm.assert_produces_warning(None):
c_old = Categorical([0, 1, 2, 0, 1, 2], categories=[3, 4, 5]) # noqa
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/arrays/categorical/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_categorical_repr_timedelta(self):

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

assert repr(c) == exp

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

assert repr(c) == exp

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

assert repr(c) == exp

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/sparse/test_libsparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def test_check_integrity(self):

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

# also OK even though empty
index = BlockIndex(1, locs, lengths) # noqa
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)
for engine in ENGINES
)
) # noqa
)
def engine(request):
return request.param

Expand Down Expand Up @@ -1885,7 +1885,7 @@ def test_global_scope(self, engine, parser):
)

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

mid = gen[lhs]() # noqa
lhs = gen[lhs]() # noqa
rhs = gen[rhs]() # noqa
lhs = gen[lhs]()
rhs = gen[rhs]()

ex1 = f"lhs {cmp} mid {cmp} rhs"
ex2 = f"lhs {cmp} mid and mid {cmp} rhs"
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ def test_nan_to_nat_conversions():

@td.skip_if_no_scipy
@pytest.mark.filterwarnings("ignore::PendingDeprecationWarning")
def test_is_scipy_sparse(spmatrix): # noqa: F811
def test_is_scipy_sparse(spmatrix):
assert is_scipy_sparse(spmatrix([[0, 1]]))
assert not is_scipy_sparse(np.array([1]))

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def test_getitem_setitem_float_labels(self):
cp.iloc[1.0:5] = 0

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

assert result.values.all()
assert (cp.iloc[0:1] == df.iloc[0:1]).values.all()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_consolidate_inplace(self, float_frame):
def test_values_consolidate(self, float_frame):
float_frame["E"] = 7.0
assert not float_frame._mgr.is_consolidated()
_ = float_frame.values # noqa
_ = float_frame.values
assert float_frame._mgr.is_consolidated()

def test_modify_values(self, float_frame):
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/frame/test_query_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,7 @@ def test_chained_cmp_and_in(self):
res = df.query(
"a < b < c and a not in b not in c", engine=engine, parser=parser
)
ind = (
(df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) & ~df.c.isin(df.b)
) # noqa
ind = (df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) & ~df.c.isin(df.b)
expec = df[ind]
tm.assert_frame_equal(res, expec)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/categorical/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_string_categorical_index_repr(self):
expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')""" # noqa
categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""

assert repr(idx) == expected

Expand Down Expand Up @@ -49,7 +49,7 @@ def test_string_categorical_index_repr(self):
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""

assert repr(idx) == expected

Expand Down Expand Up @@ -84,7 +84,7 @@ def test_string_categorical_index_repr(self):
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')"""

assert repr(idx) == expected

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,5 @@ def test_tuple_width(self, wide_multi_index):
('abc', 10, '2000-01-01 00:33:17', '2000-01-01 00:33:17', ...),
('abc', 10, '2000-01-01 00:33:18', '2000-01-01 00:33:18', ...),
('abc', 10, '2000-01-01 00:33:19', '2000-01-01 00:33:19', ...)],
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'], length=2000)""" # noqa
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'], length=2000)"""
assert result == expected
2 changes: 1 addition & 1 deletion pandas/tests/indexes/multi/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_unsortedindex():


def test_unsortedindex_doc_examples():
# https://pandas.pydata.org/pandas-docs/stable/advanced.html#sorting-a-multiindex # noqa
# https://pandas.pydata.org/pandas-docs/stable/advanced.html#sorting-a-multiindex
dfm = DataFrame(
{"jim": [0, 0, 1, 1], "joe": ["x", "x", "z", "y"], "jolie": np.random.rand(4)}
)
Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/indexing/test_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def test_frame_loc_callable(self):
res = df.loc[lambda x: x.A > 2]
tm.assert_frame_equal(res, df.loc[df.A > 2])

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

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

res = df.loc[lambda x: x.B == "b", :]
tm.assert_frame_equal(res, df.loc[df.B == "b", :])
Expand Down Expand Up @@ -90,8 +90,8 @@ def test_frame_loc_callable_labels(self):
res = df.loc[lambda x: ["A", "C"]]
tm.assert_frame_equal(res, df.loc[["A", "C"]])

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

res = df.loc[lambda x: ["A", "C"], :]
tm.assert_frame_equal(res, df.loc[["A", "C"], :])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas._testing as tm

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


class TestStyler:
Expand Down
Loading