Skip to content

Commit

Permalink
ENH: extend nbQA Ruff ignored rules (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Jul 4, 2023
1 parent a348d60 commit 1bb6baf
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/repoma/check_dev_files/ruff.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def main() -> None:
"[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)",
)
executor(_check_setup_cfg)
executor(_update_nbqa_settings)
executor(_update_ruff_settings)
executor(_update_ruff_per_file_ignores)
executor(_update_ruff_pydocstyle_settings)
executor(_update_precommit_hook)
executor(_update_precommit_nbqa_hook)
executor(_update_vscode_settings)
executor(update_nbqa_settings, "ruff", to_toml_array(["--line-length=85"]))
executor.finalize()


Expand Down Expand Up @@ -78,6 +78,27 @@ def _check_setup_cfg() -> None:
raise PrecommitError(msg)


def _update_nbqa_settings() -> None:
# cspell:ignore addopts
ruff_rules = [
"--extend-ignore=B018",
"--extend-ignore=C90",
"--extend-ignore=D",
"--extend-ignore=N806",
"--extend-ignore=N816",
"--extend-ignore=PLR09",
"--extend-ignore=PLR2004",
"--extend-ignore=PLW0602",
"--extend-ignore=PLW0603",
"--line-length=85",
]
pyproject = load_pyproject()
nbqa_table = get_sub_table(pyproject, "tool.nbqa.addopts", create=True)
ruff_rules.extend(nbqa_table.get("ruff", []))
ruff_rules = sorted(set(ruff_rules))
update_nbqa_settings("ruff", to_toml_array(ruff_rules))


def _update_ruff_settings() -> None:
pyproject = load_pyproject()
settings = get_sub_table(pyproject, "tool.ruff", create=True)
Expand Down

0 comments on commit 1bb6baf

Please sign in to comment.