diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f669ee77c3eb..d0c9f12614d0d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/asv_bench/benchmarks/pandas_vb_common.py b/asv_bench/benchmarks/pandas_vb_common.py index 23286343d7367..7bd4d639633b3 100644 --- a/asv_bench/benchmarks/pandas_vb_common.py +++ b/asv_bench/benchmarks/pandas_vb_common.py @@ -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 diff --git a/asv_bench/benchmarks/tslibs/offsets.py b/asv_bench/benchmarks/tslibs/offsets.py index fc1efe63307b2..0aea8332398b1 100644 --- a/asv_bench/benchmarks/tslibs/offsets.py +++ b/asv_bench/benchmarks/tslibs/offsets.py @@ -9,7 +9,7 @@ from pandas import offsets try: - import pandas.tseries.holiday # noqa + import pandas.tseries.holiday except ImportError: pass diff --git a/doc/source/conf.py b/doc/source/conf.py index 04540f7e6ec95..15e7a13ff5b72 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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__) @@ -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): diff --git a/pandas/_typing.py b/pandas/_typing.py index 16d81c0d39cbe..7678d1bf12d8b 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -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 diff --git a/pandas/api/types/__init__.py b/pandas/api/types/__init__.py index 3495b493707c2..fb1abdd5b18ec 100644 --- a/pandas/api/types/__init__.py +++ b/pandas/api/types/__init__.py @@ -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, diff --git a/pandas/conftest.py b/pandas/conftest.py index 3865d287c6905..5ac5e3670f69f 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -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:" diff --git a/pandas/core/arrays/floating.py b/pandas/core/arrays/floating.py index c3710196a8611..33659fe2f397d 100644 --- a/pandas/core/arrays/floating.py +++ b/pandas/core/arrays/floating.py @@ -34,7 +34,7 @@ from .masked import BaseMaskedArray, BaseMaskedDtype if TYPE_CHECKING: - import pyarrow # noqa: F401 + import pyarrow class FloatingDtype(BaseMaskedDtype): @@ -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 diff --git a/pandas/io/common.py b/pandas/io/common.py index f177e08ac0089..c147ae9fd0aa8 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -53,7 +53,7 @@ if TYPE_CHECKING: - from io import IOBase # noqa: F401 + from io import IOBase def is_url(url) -> bool: diff --git a/pandas/io/formats/console.py b/pandas/io/formats/console.py index bed29e1fd4792..50e69f7e8b435 100644 --- a/pandas/io/formats/console.py +++ b/pandas/io/formats/console.py @@ -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() @@ -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 diff --git a/pandas/io/formats/info.py b/pandas/io/formats/info.py index e8e41d4325103..5c6ce23707781 100644 --- a/pandas/io/formats/info.py +++ b/pandas/io/formats/info.py @@ -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: diff --git a/pandas/io/json/_table_schema.py b/pandas/io/json/_table_schema.py index 84146a5d732e1..2b4c86b3c4406 100644 --- a/pandas/io/json/_table_schema.py +++ b/pandas/io/json/_table_schema.py @@ -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 diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index d62480baed71e..ef9a4526a3fab 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -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 diff --git a/pandas/io/sas/sasreader.py b/pandas/io/sas/sasreader.py index 893a6286f74d4..caf53b5be971a 100644 --- a/pandas/io/sas/sasreader.py +++ b/pandas/io/sas/sasreader.py @@ -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 diff --git a/pandas/plotting/_matplotlib/__init__.py b/pandas/plotting/_matplotlib/__init__.py index 27b1d55fe1bd6..33011e6a66cac 100644 --- a/pandas/plotting/_matplotlib/__init__.py +++ b/pandas/plotting/_matplotlib/__init__.py @@ -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, diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index f8faac6a6a026..64cd43c230f28 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -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 diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index aed0c360fc7ce..832957dd73ec7 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -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 diff --git a/pandas/tests/arrays/categorical/test_constructors.py b/pandas/tests/arrays/categorical/test_constructors.py index e200f13652a84..1eef86980f974 100644 --- a/pandas/tests/arrays/categorical/test_constructors.py +++ b/pandas/tests/arrays/categorical/test_constructors.py @@ -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 diff --git a/pandas/tests/arrays/categorical/test_repr.py b/pandas/tests/arrays/categorical/test_repr.py index 735b062eae80e..e23fbb16190ea 100644 --- a/pandas/tests/arrays/categorical/test_repr.py +++ b/pandas/tests/arrays/categorical/test_repr.py @@ -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 @@ -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 diff --git a/pandas/tests/arrays/sparse/test_libsparse.py b/pandas/tests/arrays/sparse/test_libsparse.py index 2d6e657debdb2..517dc4a2c3d8b 100644 --- a/pandas/tests/arrays/sparse/test_libsparse.py +++ b/pandas/tests/arrays/sparse/test_libsparse.py @@ -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 diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index cca64a6bf487c..bce1695b56a99 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -48,7 +48,7 @@ ) for engine in ENGINES ) -) # noqa +) def engine(request): return request.param @@ -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() @@ -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" diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index e40a12f7bc8d1..c6c54ccb357d5 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -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])) diff --git a/pandas/tests/frame/indexing/test_indexing.py b/pandas/tests/frame/indexing/test_indexing.py index b947be705a329..507d01f5b900c 100644 --- a/pandas/tests/frame/indexing/test_indexing.py +++ b/pandas/tests/frame/indexing/test_indexing.py @@ -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() diff --git a/pandas/tests/frame/test_block_internals.py b/pandas/tests/frame/test_block_internals.py index 4a85da72bc8b1..1e404c572dd51 100644 --- a/pandas/tests/frame/test_block_internals.py +++ b/pandas/tests/frame/test_block_internals.py @@ -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): diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index 2994482fa5139..024403189409c 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -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) diff --git a/pandas/tests/indexes/categorical/test_formats.py b/pandas/tests/indexes/categorical/test_formats.py index a5607224f6448..45089fd876ffc 100644 --- a/pandas/tests/indexes/categorical/test_formats.py +++ b/pandas/tests/indexes/categorical/test_formats.py @@ -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 @@ -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 @@ -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 diff --git a/pandas/tests/indexes/multi/test_formats.py b/pandas/tests/indexes/multi/test_formats.py index 792dcf4c535e3..c1de7f79c2d2e 100644 --- a/pandas/tests/indexes/multi/test_formats.py +++ b/pandas/tests/indexes/multi/test_formats.py @@ -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 diff --git a/pandas/tests/indexes/multi/test_sorting.py b/pandas/tests/indexes/multi/test_sorting.py index 423bbed831b87..a1e5cc33ef2f6 100644 --- a/pandas/tests/indexes/multi/test_sorting.py +++ b/pandas/tests/indexes/multi/test_sorting.py @@ -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)} ) diff --git a/pandas/tests/indexing/test_callable.py b/pandas/tests/indexing/test_callable.py index bf51c3e5d1695..b98c9a3df0438 100644 --- a/pandas/tests/indexing/test_callable.py +++ b/pandas/tests/indexing/test_callable.py @@ -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", :]) @@ -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"], :]) diff --git a/pandas/tests/io/formats/test_style.py b/pandas/tests/io/formats/test_style.py index 8d66a16fc2b7a..476d75f7d239d 100644 --- a/pandas/tests/io/formats/test_style.py +++ b/pandas/tests/io/formats/test_style.py @@ -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: diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 9278e64cc911f..822342113f62a 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -987,7 +987,7 @@ def test_round_trip_exception_(self): ], ) def test_url(self, field, dtype): - url = "https://api.github.com/repos/pandas-dev/pandas/issues?per_page=5" # noqa + url = "https://api.github.com/repos/pandas-dev/pandas/issues?per_page=5" result = read_json(url, convert_dates=True) assert result[field].dtype == dtype diff --git a/pandas/tests/io/parser/test_index_col.py b/pandas/tests/io/parser/test_index_col.py index 9f425168540ba..4d64f2bf411bd 100644 --- a/pandas/tests/io/parser/test_index_col.py +++ b/pandas/tests/io/parser/test_index_col.py @@ -21,7 +21,7 @@ def test_index_col_named(all_parsers, with_header): KORD3,19990127, 21:00:00, 20:56:00, -0.5900, 2.2100, 5.7000, 0.0000, 280.0000 KORD4,19990127, 21:00:00, 21:18:00, -0.9900, 2.0100, 3.6000, 0.0000, 270.0000 KORD5,19990127, 22:00:00, 21:56:00, -0.5900, 1.7100, 5.1000, 0.0000, 290.0000 -KORD6,19990127, 23:00:00, 22:56:00, -0.5900, 1.7100, 4.6000, 0.0000, 280.0000""" # noqa +KORD6,19990127, 23:00:00, 22:56:00, -0.5900, 1.7100, 4.6000, 0.0000, 280.0000""" header = "ID,date,NominalTime,ActualTime,TDew,TAir,Windspeed,Precip,WindDir\n" if with_header: diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index ccb2efbd2c630..c1938db12a0bc 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -52,8 +52,8 @@ read_hdf, ) -from pandas.io import pytables as pytables # noqa: E402 isort:skip -from pandas.io.pytables import TableIterator # noqa: E402 isort:skip +from pandas.io import pytables as pytables # isort:skip +from pandas.io.pytables import TableIterator # isort:skip _default_compressor = "blosc" @@ -512,7 +512,7 @@ def check(mode): # context if mode in ["r", "r+"]: with pytest.raises(IOError): - with HDFStore(path, mode=mode) as store: # noqa + with HDFStore(path, mode=mode) as store: pass else: with HDFStore(path, mode=mode) as store: @@ -2350,7 +2350,7 @@ def test_same_name_scoping(self, setup_path): store.put("df", df, format="table") expected = df[df.index > pd.Timestamp("20130105")] - import datetime # noqa + import datetime result = store.select("df", "index>datetime.datetime(2013,1,5)") tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/io/test_feather.py b/pandas/tests/io/test_feather.py index c1e63f512b53e..cef5d28b8ccf0 100644 --- a/pandas/tests/io/test_feather.py +++ b/pandas/tests/io/test_feather.py @@ -9,7 +9,7 @@ import pandas as pd import pandas._testing as tm -from pandas.io.feather_format import read_feather, to_feather # noqa: E402 isort:skip +from pandas.io.feather_format import read_feather, to_feather # isort:skip pyarrow = pytest.importorskip("pyarrow") diff --git a/pandas/tests/io/test_gcs.py b/pandas/tests/io/test_gcs.py index 9d179d983ceeb..65e174cd32e22 100644 --- a/pandas/tests/io/test_gcs.py +++ b/pandas/tests/io/test_gcs.py @@ -14,7 +14,7 @@ def gcs_buffer(monkeypatch): """Emulate GCS using a binary buffer.""" from fsspec import AbstractFileSystem, registry - registry.target.clear() # noqa # remove state + registry.target.clear() # remove state gcs_buffer = BytesIO() gcs_buffer.close = lambda: True @@ -33,7 +33,7 @@ def open(*args, **kwargs): def test_read_csv_gcs(gcs_buffer): from fsspec import registry - registry.target.clear() # noqa # remove state + registry.target.clear() # remove state df1 = DataFrame( { @@ -55,7 +55,7 @@ def test_read_csv_gcs(gcs_buffer): def test_to_csv_gcs(gcs_buffer): from fsspec import registry - registry.target.clear() # noqa # remove state + registry.target.clear() # remove state df1 = DataFrame( { @@ -84,7 +84,7 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding) """ from fsspec import registry - registry.target.clear() # noqa # remove state + registry.target.clear() # remove state df = tm.makeDataFrame() # reference of compressed and encoded file @@ -120,7 +120,7 @@ def test_to_parquet_gcs_new_file(monkeypatch, tmpdir): """Regression test for writing to a not-yet-existent GCS Parquet file.""" from fsspec import AbstractFileSystem, registry - registry.target.clear() # noqa # remove state + registry.target.clear() # remove state df1 = DataFrame( { "int": [1, 3], diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index b7c8ca7e0c49f..f7b25f8c0eeac 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -24,14 +24,14 @@ ) try: - import pyarrow # noqa + import pyarrow _HAVE_PYARROW = True except ImportError: _HAVE_PYARROW = False try: - import fastparquet # noqa + import fastparquet _HAVE_FASTPARQUET = True except ImportError: @@ -818,7 +818,7 @@ def test_partition_cols_supported(self, fp, df_full): compression=None, ) assert os.path.exists(path) - import fastparquet # noqa: F811 + import fastparquet actual_partition_cols = fastparquet.ParquetFile(path, False).cats assert len(actual_partition_cols) == 2 @@ -835,7 +835,7 @@ def test_partition_cols_string(self, fp, df_full): compression=None, ) assert os.path.exists(path) - import fastparquet # noqa: F811 + import fastparquet actual_partition_cols = fastparquet.ParquetFile(path, False).cats assert len(actual_partition_cols) == 1 @@ -852,7 +852,7 @@ def test_partition_on_supported(self, fp, df_full): partition_on=partition_cols, ) assert os.path.exists(path) - import fastparquet # noqa: F811 + import fastparquet actual_partition_cols = fastparquet.ParquetFile(path, False).cats assert len(actual_partition_cols) == 2 diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index ca4c2bdcc2fe1..bdb86d2dd846f 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -3448,7 +3448,7 @@ def test_xlabel_ylabel_dataframe_subplots( def _generate_4_axes_via_gridspec(): import matplotlib as mpl - import matplotlib.gridspec # noqa + import matplotlib.gridspec import matplotlib.pyplot as plt gs = mpl.gridspec.GridSpec(2, 2) diff --git a/pandas/tests/scalar/timestamp/test_constructors.py b/pandas/tests/scalar/timestamp/test_constructors.py index d1c3ad508d877..583110cc4ba70 100644 --- a/pandas/tests/scalar/timestamp/test_constructors.py +++ b/pandas/tests/scalar/timestamp/test_constructors.py @@ -135,7 +135,7 @@ def test_constructor_with_stringoffset(self): # converted to Chicago tz result = Timestamp("2013-11-01 00:00:00-0500", tz="America/Chicago") assert result.value == Timestamp("2013-11-01 05:00").value - expected = "Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago')" # noqa + expected = "Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago')" assert repr(result) == expected assert result == eval(repr(result)) diff --git a/pandas/tests/series/test_repr.py b/pandas/tests/series/test_repr.py index 3aaecc37df56c..32e1220f83f40 100644 --- a/pandas/tests/series/test_repr.py +++ b/pandas/tests/series/test_repr.py @@ -486,7 +486,7 @@ def test_categorical_series_repr_timedelta_ordered(self): 3 4 days 4 5 days dtype: category -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(s) == exp diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index f7f3f1fa0c13d..17d7527a2b687 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -21,7 +21,7 @@ def test_get_callable_name(): def fn(x): return x - lambda_ = lambda x: x # noqa: E731 + lambda_ = lambda x: x part1 = partial(fn) part2 = partial(part1) diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index b32c5e91af295..c03e8e26952e5 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -20,7 +20,7 @@ def import_module(name): try: return importlib.import_module(name) - except ModuleNotFoundError: # noqa + except ModuleNotFoundError: pytest.skip(f"skipping as {name} not available") @@ -117,7 +117,7 @@ def test_pandas_gbq(df): @tm.network def test_pandas_datareader(): - pandas_datareader = import_module("pandas_datareader") # noqa + pandas_datareader = import_module("pandas_datareader") pandas_datareader.DataReader("F", "quandl", "2017-01-01", "2017-02-01") @@ -125,7 +125,7 @@ def test_pandas_datareader(): @pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning") def test_geopandas(): - geopandas = import_module("geopandas") # noqa + geopandas = import_module("geopandas") fp = geopandas.datasets.get_path("naturalearth_lowres") assert geopandas.read_file(fp) is not None @@ -135,7 +135,7 @@ def test_geopandas(): @pytest.mark.filterwarnings("ignore:RangeIndex.* is deprecated:DeprecationWarning") def test_pyarrow(df): - pyarrow = import_module("pyarrow") # noqa + pyarrow = import_module("pyarrow") table = pyarrow.Table.from_pandas(df) result = table.to_pandas() tm.assert_frame_equal(result, df) diff --git a/pandas/tests/test_errors.py b/pandas/tests/test_errors.py index 6a1a74c73288f..6207b886b95c7 100644 --- a/pandas/tests/test_errors.py +++ b/pandas/tests/test_errors.py @@ -2,7 +2,7 @@ from pandas.errors import AbstractMethodError -import pandas as pd # noqa +import pandas as pd @pytest.mark.parametrize( diff --git a/scripts/validate_docstrings.py b/scripts/validate_docstrings.py index 7971379ca60c1..8b15358834066 100755 --- a/scripts/validate_docstrings.py +++ b/scripts/validate_docstrings.py @@ -35,19 +35,19 @@ # script. Setting here before matplotlib is loaded. # We don't warn for the number of open plots, as none is actually being opened os.environ["MPLBACKEND"] = "Template" -import matplotlib # noqa: E402 isort:skip +import matplotlib # isort:skip matplotlib.rc("figure", max_open_warning=10000) -import numpy # noqa: E402 isort:skip +import numpy # isort:skip BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(BASE_PATH)) -import pandas # noqa: E402 isort:skip +import pandas # isort:skip sys.path.insert(1, os.path.join(BASE_PATH, "doc", "sphinxext")) -from numpydoc.validate import validate, Docstring # noqa: E402 isort:skip +from numpydoc.validate import validate, Docstring # isort:skip PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"] diff --git a/setup.py b/setup.py index 8e25705c1f4c3..9a9d12ce4d2ba 100755 --- a/setup.py +++ b/setup.py @@ -51,8 +51,8 @@ def is_platform_mac(): # The import of Extension must be after the import of Cython, otherwise # we do not get the appropriately patched class. # See https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html # noqa -from distutils.extension import Extension # noqa: E402 isort:skip -from distutils.command.build import build # noqa: E402 isort:skip +from distutils.extension import Extension # isort:skip +from distutils.command.build import build # isort:skip if _CYTHON_INSTALLED: from Cython.Distutils.old_build_ext import old_build_ext as _build_ext