diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82043f79643e4..dfef9844ce6cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,10 @@ default_stages: [ ci: autofix_prs: false repos: +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.215 + hooks: + - id: ruff - repo: https://github.com/MarcoGorelli/absolufy-imports rev: v0.3.1 hooks: @@ -66,13 +70,6 @@ repos: --linelength=88, '--filter=-readability/casting,-runtime/int,-build/include_subdir,-readability/fn_size' ] -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: &flake8_dependencies - - flake8==6.0.0 - - flake8-bugbear==22.7.1 - repo: https://github.com/pycqa/pylint rev: v2.15.9 hooks: @@ -117,12 +114,6 @@ repos: rev: v0.6.7 hooks: - id: sphinx-lint -- repo: https://github.com/asottile/yesqa - rev: v1.4.0 - hooks: - - id: yesqa - additional_dependencies: *flake8_dependencies - stages: [manual] - repo: local hooks: # NOTE: we make `black` a local hook because if it's installed from @@ -326,13 +317,6 @@ repos: files: ^(environment.yml|requirements-dev.txt)$ pass_filenames: false additional_dependencies: [pyyaml, toml] - - id: sync-flake8-versions - name: Check flake8 version is synced across flake8, yesqa, and environment.yml - language: python - entry: python scripts/sync_flake8_versions.py - files: ^(\.pre-commit-config\.yaml|environment\.yml)$ - pass_filenames: false - additional_dependencies: [pyyaml, toml] - id: title-capitalization name: Validate correct capitalization among titles in documentation entry: python scripts/validate_rst_title_capitalization.py diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 2f73cf08823b7..b619523b16eef 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -43,7 +43,7 @@ Pre-commit ---------- Additionally, :ref:`Continuous Integration ` will run code formatting checks -like ``black``, ``flake8``, +like ``black``, ``ruff``, ``isort``, and ``cpplint`` and more using `pre-commit hooks `_ Any warnings from these checks will cause the :ref:`Continuous Integration ` to fail; therefore, it is helpful to run the check yourself before submitting code. This diff --git a/environment.yml b/environment.yml index 96753f0f1c9b3..9e4c6db82b2ce 100644 --- a/environment.yml +++ b/environment.yml @@ -78,12 +78,11 @@ dependencies: - black=22.10.0 - cpplint - flake8=6.0.0 - - flake8-bugbear=22.7.1 # used by flake8, find likely bugs - isort>=5.2.1 # check that imports are in the right order - mypy=0.991 - pre-commit>=2.15.0 - - pycodestyle # used by flake8 - pyupgrade + - ruff=0.0.215 # documentation - gitpython # obtain contributors from git for whatsnew diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index 446f830d4100b..04a6f6c6277ee 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -242,7 +242,7 @@ def stringify(value): return TermValue(v, v, kind) elif kind == "bool": if isinstance(v, str): - v = not v.strip().lower() in [ + v = v.strip().lower() not in [ "false", "f", "no", diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 561422c868e91..e4cde8b25f4b4 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10848,7 +10848,7 @@ def _accum_func( if axis == 1: return self.T._accum_func( - name, func, axis=0, skipna=skipna, *args, **kwargs + name, func, axis=0, skipna=skipna, *args, **kwargs # noqa: B026 ).T def block_accum_func(blk_values): diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index dceff32108c63..8d009d25a66ba 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -10,6 +10,7 @@ from typing import ( TYPE_CHECKING, Hashable, + Literal, Sequence, cast, ) @@ -31,7 +32,6 @@ DtypeObj, IndexLabel, JoinHow, - Literal, MergeHow, Shape, Suffixes, diff --git a/pandas/io/formats/latex.py b/pandas/io/formats/latex.py index b2622e61896a0..a97f3d4ef541e 100644 --- a/pandas/io/formats/latex.py +++ b/pandas/io/formats/latex.py @@ -54,7 +54,7 @@ def _split_into_full_short_caption( return full_caption, short_caption -class RowStringConverter(ABC): +class RowStringConverter: r"""Converter for dataframe rows into LaTeX strings. Parameters diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index fbafb772c59d6..0d2aca8b78112 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -2253,7 +2253,7 @@ def set_sticky( "props": props + "top:0px; z-index:2;", } ] - if not self.index.names[0] is None: + if self.index.names[0] is not None: styles[0]["props"] = ( props + f"top:0px; z-index:2; height:{pixel_size}px;" ) diff --git a/pandas/io/parsers/python_parser.py b/pandas/io/parsers/python_parser.py index ec19cbf3c7cfd..e97aac82a50ff 100644 --- a/pandas/io/parsers/python_parser.py +++ b/pandas/io/parsers/python_parser.py @@ -1017,12 +1017,12 @@ def _rows_to_cols(self, content: list[list[Scalar]]) -> list[np.ndarray]: content_len = len(content) content = [] - for (i, l) in iter_content: - actual_len = len(l) + for (i, _content) in iter_content: + actual_len = len(_content) if actual_len > col_len: if callable(self.on_bad_lines): - new_l = self.on_bad_lines(l) + new_l = self.on_bad_lines(_content) if new_l is not None: content.append(new_l) elif self.on_bad_lines in ( @@ -1035,7 +1035,7 @@ def _rows_to_cols(self, content: list[list[Scalar]]) -> list[np.ndarray]: if self.on_bad_lines == self.BadLineHandleMethod.ERROR: break else: - content.append(l) + content.append(_content) for row_num, actual_len in bad_lines: msg = ( diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 3a634a60e784e..68f896755e922 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -455,6 +455,7 @@ def generate(self) -> None: self._post_plot_logic_common(ax, self.data) self._post_plot_logic(ax, self.data) + @abstractmethod def _args_adjust(self) -> None: pass @@ -664,6 +665,7 @@ def _post_plot_logic_common(self, ax, data): else: # pragma no cover raise ValueError + @abstractmethod def _post_plot_logic(self, ax, data) -> None: """Post process for each axes. Overridden in child classes""" @@ -1278,6 +1280,9 @@ def _make_plot(self): err_kwds["ecolor"] = scatter.get_facecolor()[0] ax.errorbar(data[x].values, data[y].values, linestyle="none", **err_kwds) + def _args_adjust(self) -> None: + pass + class HexBinPlot(PlanePlot): @property @@ -1310,6 +1315,9 @@ def _make_plot(self) -> None: def _make_legend(self) -> None: pass + def _args_adjust(self) -> None: + pass + class LinePlot(MPLPlot): _default_rot = 0 @@ -1469,6 +1477,9 @@ def _update_stacker(cls, ax: Axes, stacking_id, values) -> None: elif (values <= 0).all(): ax._stacker_neg_prior[stacking_id] += values + def _args_adjust(self) -> None: + pass + def _post_plot_logic(self, ax: Axes, data) -> None: from matplotlib.ticker import FixedLocator @@ -1573,6 +1584,9 @@ def _plot( # type: ignore[override] res = [rect] return res + def _args_adjust(self) -> None: + pass + def _post_plot_logic(self, ax: Axes, data) -> None: LinePlot._post_plot_logic(self, ax, data) @@ -1855,5 +1869,8 @@ def blank_labeler(label, value): # leglabels is used for legend labels leglabels = labels if labels is not None else idx - for p, l in zip(patches, leglabels): - self._append_legend_handles_labels(p, l) + for _patch, _leglabel in zip(patches, leglabels): + self._append_legend_handles_labels(_patch, _leglabel) + + def _post_plot_logic(self, ax: Axes, data) -> None: + pass diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index 25e31d8064c29..02188a6e57534 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -201,13 +201,13 @@ def test_nat_comparisons( expected, ): box = index_or_series - l, r = pair + lhs, rhs = pair if reverse: # add lhs / rhs switched data - l, r = r, l + lhs, rhs = rhs, lhs - left = Series(l, dtype=dtype) - right = box(r, dtype=dtype) + left = Series(lhs, dtype=dtype) + right = box(rhs, dtype=dtype) result = op(left, right) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 0496cfcb6f569..3257c3d4bd128 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2469,7 +2469,7 @@ def test_dict_nocopy( if ( using_array_manager and not copy - and not (any_numpy_dtype in (tm.STRING_DTYPES + tm.BYTES_DTYPES)) + and any_numpy_dtype not in tm.STRING_DTYPES + tm.BYTES_DTYPES ): # TODO(ArrayManager) properly honor copy keyword for dict input td.mark_array_manager_not_yet_implemented(request) diff --git a/pandas/tests/indexes/period/test_indexing.py b/pandas/tests/indexes/period/test_indexing.py index 6cf942ad3d5d5..4fe1e471db434 100644 --- a/pandas/tests/indexes/period/test_indexing.py +++ b/pandas/tests/indexes/period/test_indexing.py @@ -778,8 +778,8 @@ def test_contains_freq_mismatch(self): rng = period_range("2007-01", freq="M", periods=10) assert Period("2007-01", freq="M") in rng - assert not Period("2007-01", freq="D") in rng - assert not Period("2007-01", freq="2M") in rng + assert Period("2007-01", freq="D") not in rng + assert Period("2007-01", freq="2M") not in rng def test_contains_nat(self): # see gh-13582 diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py index f5aa481b2172e..d04e5183d980f 100644 --- a/pandas/tests/io/formats/test_format.py +++ b/pandas/tests/io/formats/test_format.py @@ -134,7 +134,7 @@ def has_horizontally_truncated_repr(df): return False # Make sure each row has this ... in the same place r = repr(df) - for ix, l in enumerate(r.splitlines()): + for ix, _ in enumerate(r.splitlines()): if not r.split()[cand_col] == "...": return False return True diff --git a/pandas/tests/io/test_html.py b/pandas/tests/io/test_html.py index 4d0f99b93ac5f..f8284b5ab1c65 100644 --- a/pandas/tests/io/test_html.py +++ b/pandas/tests/io/test_html.py @@ -405,10 +405,8 @@ def test_invalid_table_attrs(self, banklist_data): url, match="First Federal Bank of Florida", attrs={"id": "tasdfable"} ) - def _bank_data(self, path, *args, **kwargs): - return self.read_html( - path, match="Metcalf", attrs={"id": "table"}, *args, **kwargs - ) + def _bank_data(self, path, **kwargs): + return self.read_html(path, match="Metcalf", attrs={"id": "table"}, **kwargs) @pytest.mark.slow def test_multiindex_header(self, banklist_data): diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 3149fa9cb2095..f145c8d750e12 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -1021,10 +1021,10 @@ def test_time(self): # verify tick labels ticks = ax.get_xticks() labels = ax.get_xticklabels() - for t, l in zip(ticks, labels): - m, s = divmod(int(t), 60) + for _tick, _label in zip(ticks, labels): + m, s = divmod(int(_tick), 60) h, m = divmod(m, 60) - rs = l.get_text() + rs = _label.get_text() if len(rs) > 0: if s != 0: xp = time(h, m, s).strftime("%H:%M:%S") @@ -1045,10 +1045,10 @@ def test_time_change_xlim(self): # verify tick labels ticks = ax.get_xticks() labels = ax.get_xticklabels() - for t, l in zip(ticks, labels): - m, s = divmod(int(t), 60) + for _tick, _label in zip(ticks, labels): + m, s = divmod(int(_tick), 60) h, m = divmod(m, 60) - rs = l.get_text() + rs = _label.get_text() if len(rs) > 0: if s != 0: xp = time(h, m, s).strftime("%H:%M:%S") @@ -1062,10 +1062,10 @@ def test_time_change_xlim(self): # check tick labels again ticks = ax.get_xticks() labels = ax.get_xticklabels() - for t, l in zip(ticks, labels): - m, s = divmod(int(t), 60) + for _tick, _label in zip(ticks, labels): + m, s = divmod(int(_tick), 60) h, m = divmod(m, 60) - rs = l.get_text() + rs = _label.get_text() if len(rs) > 0: if s != 0: xp = time(h, m, s).strftime("%H:%M:%S") @@ -1086,13 +1086,13 @@ def test_time_musec(self): # verify tick labels ticks = ax.get_xticks() labels = ax.get_xticklabels() - for t, l in zip(ticks, labels): - m, s = divmod(int(t), 60) + for _tick, _label in zip(ticks, labels): + m, s = divmod(int(_tick), 60) - us = round((t - int(t)) * 1e6) + us = round((_tick - int(_tick)) * 1e6) h, m = divmod(m, 60) - rs = l.get_text() + rs = _label.get_text() if len(rs) > 0: if (us % 1000) != 0: xp = time(h, m, s, us).strftime("%H:%M:%S.%f") diff --git a/pandas/util/_doctools.py b/pandas/util/_doctools.py index 6144d1a179828..9e3ab80d1d40a 100644 --- a/pandas/util/_doctools.py +++ b/pandas/util/_doctools.py @@ -77,9 +77,9 @@ def plot(self, left, right, labels: Iterable[str] = (), vertical: bool = True): # left max_left_cols = max(self._shape(df)[1] for df in left) max_left_rows = max(self._shape(df)[0] for df in left) - for i, (l, label) in enumerate(zip(left, labels)): + for i, (_left, _label) in enumerate(zip(left, labels)): ax = fig.add_subplot(gs[i, 0:max_left_cols]) - self._make_table(ax, l, title=label, height=1.0 / max_left_rows) + self._make_table(ax, _left, title=_label, height=1.0 / max_left_rows) # right ax = plt.subplot(gs[:, max_left_cols:]) self._make_table(ax, right, title="Result", height=1.05 / vcells) @@ -90,10 +90,10 @@ def plot(self, left, right, labels: Iterable[str] = (), vertical: bool = True): gs = gridspec.GridSpec(1, hcells) # left i = 0 - for df, label in zip(left, labels): + for df, _label in zip(left, labels): sp = self._shape(df) ax = fig.add_subplot(gs[0, i : i + sp[1]]) - self._make_table(ax, df, title=label, height=height) + self._make_table(ax, df, title=_label, height=height) i += sp[1] # right ax = plt.subplot(gs[0, i:]) diff --git a/pyproject.toml b/pyproject.toml index 385c1beb08121..a41204590bcf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -184,6 +184,76 @@ exclude = ''' ) ''' +[tool.ruff] +line-length = 88 +update-check = false +target-version = "py38" + +select = [ + # pyflakes + "F", + # pycodestyle + "E", + "W", + # flake8-2020 + "YTT", + # flake8-bugbear + "B", + # flake8-quotes + "Q", + # pylint + "PLE", "PLR", "PLW", +] + +ignore = [ + # space before : (needed for how black formats slicing) + # "E203", # not yet implemented + # module level import not at top of file + "E402", + # do not assign a lambda expression, use a def + "E731", + # line break before binary operator + # "W503", # not yet implemented + # line break after binary operator + # "W504", # not yet implemented + # controversial + "B006", + # controversial + "B007", + # controversial + "B008", + # setattr is used to side-step mypy + "B009", + # getattr is used to side-step mypy + "B010", + # tests use assert False + "B011", + # tests use comparisons but not their returned value + "B015", + # false positives + "B019", + # Loop control variable overrides iterable it iterates + "B020", + # Function definition does not bind loop variable + "B023", + # Functions defined inside a loop must not use variables redefined in the loop + # "B301", # not yet implemented + + # Additional checks that don't pass yet + # Within an except clause, raise exceptions with ... + "B904", +] + +exclude = [ + "doc/sphinxext/*.py", + "doc/build/*.py", + "doc/temp/*.py", + ".eggs/*.py", + "versioneer.py", + # exclude asv benchmark environments from linting + "env", +] + [tool.pylint.messages_control] max-line-length = 88 disable = [ diff --git a/requirements-dev.txt b/requirements-dev.txt index 975783a83d1f6..1a2e39bb47786 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -55,12 +55,11 @@ asv>=0.5.1 black==22.10.0 cpplint flake8==6.0.0 -flake8-bugbear==22.7.1 isort>=5.2.1 mypy==0.991 pre-commit>=2.15.0 -pycodestyle pyupgrade +ruff==0.0.215 gitpython gitdb natsort diff --git a/scripts/no_bool_in_generic.py b/scripts/no_bool_in_generic.py index f63ae4ae1659c..92e2c0983b25b 100644 --- a/scripts/no_bool_in_generic.py +++ b/scripts/no_bool_in_generic.py @@ -19,7 +19,7 @@ def visit(tree: ast.Module) -> dict[int, list[int]]: - "Step through tree, recording when nodes are in annotations." + """Step through tree, recording when nodes are in annotations.""" in_annotation = False nodes: list[tuple[bool, ast.AST]] = [(in_annotation, tree)] to_replace = collections.defaultdict(list) diff --git a/scripts/sync_flake8_versions.py b/scripts/sync_flake8_versions.py deleted file mode 100644 index 0d513d5937dbe..0000000000000 --- a/scripts/sync_flake8_versions.py +++ /dev/null @@ -1,137 +0,0 @@ -""" -Check that the flake8 pins are the same in: - -- environment.yml -- .pre-commit-config.yaml, in the flake8 hook -- .pre-commit-config.yaml, in the additional dependencies of the yesqa hook - -The flake8 hook revision in .pre-commit-config.yaml is taken as the reference revision. - -Usage: either - -- ``python scripts/sync_flake8_versions.py``, or -- ``pre-commit run sync-flake8-versions --all-files``. -""" -from __future__ import annotations - -from dataclasses import ( - dataclass, - replace, -) -import sys -from typing import ( - Any, - Mapping, - Sequence, - TypeVar, -) - -import yaml - - -@dataclass -class Revision: - name: str - compare: str - version: str - - -@dataclass -class Revisions: - name: str - pre_commit: Revision | None = None - yesqa: Revision | None = None - environment: Revision | None = None - - -YamlMapping = Mapping[str, Any] -Repo = TypeVar("Repo", bound=YamlMapping) - -COMPARE = ("<=", "==", ">=", "<", ">", "=") - - -def _get_repo_hook(repos: Sequence[Repo], hook_name: str) -> tuple[Repo, YamlMapping]: - for repo in repos: - for hook in repo["hooks"]: - if hook["id"] == hook_name: - return repo, hook - raise RuntimeError(f"Repo with hook {hook_name} not found") # pragma: no cover - - -def _conda_to_pip_compat(dep): - if dep.compare == "=": - return replace(dep, compare="==") - else: - return dep - - -def _validate_additional_dependencies( - flake8_additional_dependencies, - environment_additional_dependencies, -) -> None: - for dep in flake8_additional_dependencies: - if dep not in environment_additional_dependencies: - sys.stdout.write( - f"Mismatch of '{dep.name}' version between 'environment.yml' " - "and additional dependencies of 'flake8' in '.pre-commit-config.yaml'\n" - ) - sys.exit(1) - - -def _validate_revisions(revisions): - if revisions.environment != revisions.pre_commit: - sys.stdout.write( - f"{revisions.name} in 'environment.yml' does not " - "match in 'flake8' from 'pre-commit'\n" - ) - sys.exit(1) - - -def _process_dependencies(deps): - for dep in deps: - if isinstance(dep, str): - for compare in COMPARE: - if compare in dep: - pkg, rev = dep.split(compare, maxsplit=1) - yield _conda_to_pip_compat(Revision(pkg, compare, rev)) - break - else: - yield from _process_dependencies(dep["pip"]) - - -def get_revisions( - precommit_config: YamlMapping, environment: YamlMapping -) -> tuple[Revisions, Revisions]: - flake8_revisions = Revisions(name="flake8") - - repos = precommit_config["repos"] - flake8_repo, flake8_hook = _get_repo_hook(repos, "flake8") - flake8_revisions.pre_commit = Revision("flake8", "==", flake8_repo["rev"]) - flake8_additional_dependencies = [] - for dep in _process_dependencies(flake8_hook.get("additional_dependencies", [])): - flake8_additional_dependencies.append(dep) - - environment_dependencies = environment["dependencies"] - environment_additional_dependencies = [] - for dep in _process_dependencies(environment_dependencies): - if dep.name == "flake8": - flake8_revisions.environment = dep - environment_additional_dependencies.append(dep) - else: - environment_additional_dependencies.append(dep) - - _validate_additional_dependencies( - flake8_additional_dependencies, - environment_additional_dependencies, - ) - - _validate_revisions(flake8_revisions) - - -if __name__ == "__main__": - with open(".pre-commit-config.yaml") as fd: - precommit_config = yaml.safe_load(fd) - with open("environment.yml") as fd: - environment = yaml.safe_load(fd) - get_revisions(precommit_config, environment) - sys.exit(0) diff --git a/scripts/tests/test_sync_flake8_versions.py b/scripts/tests/test_sync_flake8_versions.py deleted file mode 100644 index 2349a4f5d8d1c..0000000000000 --- a/scripts/tests/test_sync_flake8_versions.py +++ /dev/null @@ -1,122 +0,0 @@ -import pytest - -from ..sync_flake8_versions import get_revisions - - -def test_wrong_env_flake8(capsys): - precommit_config = { - "repos": [ - { - "repo": "https://gitlab.com/pycqa/flake8", - "rev": "0.1.1", - "hooks": [ - { - "id": "flake8", - } - ], - }, - ] - } - environment = { - "dependencies": [ - "flake8=1.5.6", - ] - } - with pytest.raises(SystemExit, match=None): - get_revisions(precommit_config, environment) - result, _ = capsys.readouterr() - expected = ( - "flake8 in 'environment.yml' does not match in 'flake8' from 'pre-commit'\n" - ) - assert result == expected - - -def test_wrong_env_add_dep(capsys): - precommit_config = { - "repos": [ - { - "repo": "https://gitlab.com/pycqa/flake8", - "rev": "0.1.1", - "hooks": [ - { - "id": "flake8", - "additional_dependencies": [ - "flake8-bugs==1.1.1", - ], - } - ], - }, - { - "repo": "https://github.com/asottile/yesqa", - "rev": "v1.2.2", - "hooks": [ - { - "id": "yesqa", - "additional_dependencies": [ - "flake8==0.4.2", - "flake8-bugs==1.1.1", - ], - } - ], - }, - ] - } - environment = { - "dependencies": [ - "flake8=1.5.6", - "flake8-bugs=1.1.2", - ] - } - with pytest.raises(SystemExit, match=None): - get_revisions(precommit_config, environment) - result, _ = capsys.readouterr() - expected = ( - "Mismatch of 'flake8-bugs' version between 'environment.yml' " - "and additional dependencies of 'flake8' in '.pre-commit-config.yaml'\n" - ) - assert result == expected - - -def test_get_revisions_no_failure(capsys): - precommit_config = { - "repos": [ - { - "repo": "https://gitlab.com/pycqa/flake8", - "rev": "0.1.1", - "hooks": [ - { - "id": "flake8", - "additional_dependencies": [ - "flake8-bugs==1.1.1", - ], - } - ], - }, - { - "repo": "https://github.com/asottile/yesqa", - "rev": "v1.2.2", - "hooks": [ - { - "id": "yesqa", - "additional_dependencies": [ - "flake8==0.1.1", - "flake8-bugs==1.1.1", - ], - } - ], - }, - ] - } - environment = { - "dependencies": [ - "flake8=0.1.1", - "flake8-bugs=1.1.1", - { - "pip": [ - "git+https://github.com/pydata/pydata-sphinx-theme.git@master", - ] - }, - ] - } - # should not raise - get_revisions(precommit_config, environment) diff --git a/setup.cfg b/setup.cfg index 562ae70fd73ef..88b61086e1e0f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,7 @@ [flake8] max-line-length = 88 +# Although ruff is now the main linter for style checks, this section +# is still needed for validate_docstrings.py and flake8-pyi ignore = # space before : (needed for how black formats slicing) E203, @@ -12,30 +14,6 @@ ignore = # do not assign a lambda expression, use a def E731, # found modulo formatter (incorrect picks up mod operations) - S001, - # controversial - B006, - # controversial - B007, - # controversial - B008, - # setattr is used to side-step mypy - B009, - # getattr is used to side-step mypy - B010, - # tests use assert False - B011, - # tests use comparisons but not their returned value - B015, - # false positives - B019, - # Use of functools.lru_cache or functools.cache on methods can lead to memory leaks. - B020 - # Loop control variable overrides iterable it iterates - B023 - # Functions defined inside a loop must not use variables redefined in the loop - B301, - # If test must be a simple comparison against sys.platform or sys.version_info Y002, # Use "_typeshed.Self" instead of class-bound TypeVar Y019,