Skip to content

Commit

Permalink
Consolidate two ruff-pre-commit entries into one (#2881)
Browse files Browse the repository at this point in the history
* Clean up Ruff configuration in base pyproject.toml

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>

* Consolidate two `ruff-pre-commit` entries into one

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>

* Move Ruff hook to the top, because it's aggressive

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>

* Add `kedro` as `known-first-party` for `isort` run

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>

* Add noqa in docs/source/conf.py

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>

* Fix ruff linter precommit config

Signed-off-by: Nok <nok.lam.chan@quantumblack.com>

---------

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Co-authored-by: Nok <nok.lam.chan@quantumblack.com>
  • Loading branch information
deepyaman and noklam authored Aug 22, 2023
1 parent c9fc80a commit 4563a4c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
29 changes: 9 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
default_stages: [commit, manual]

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.277
hooks:
- id: ruff
name: "ruff on kedro/, tests/ and docs/"
args: ["--fix", "--exit-non-zero-on-fix"]
exclude: "^kedro/templates/|^features/steps/test_starter/"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
Expand Down Expand Up @@ -48,26 +57,6 @@ repos:
additional_dependencies: [black~=22.0]
entry: blacken-docs --skip-errors

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.277
hooks:
- id: ruff
name: "ruff on kedro/"
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
exclude: "^kedro/templates/|^features/steps/test_starter/|tests|docs"
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.277
hooks:
- id: ruff
name: "ruff on tests/ and docs/"
# PLR2004: Magic value used
# PLR0913: Too many arguments
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix", "--ignore=PLR2004,PLR0913"]
# include: "tests"
exclude: "^kedro/templates/|^features/steps/test_starter/|kedro"

- repo: local
hooks:
- id: black
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def autolink_classes_and_methods(lines):
lines[i] = re.sub(existing, rf"{replacement}", lines[i])


def autodoc_process_docstring(app, what, name, obj, options, lines):
def autodoc_process_docstring(app, what, name, obj, options, lines): # noqa: PLR0913
try:
# guarded method to make sure build never fails
log_suggestions(lines, name)
Expand Down
2 changes: 1 addition & 1 deletion kedro/framework/cli/micropkg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""A collection of CLI commands for working with Kedro micro-packages."""
# ruff: noqa: I001 # https://github.com/kedro-org/kedro/pull/2634
# ruff: noqa: I001
from __future__ import annotations

import logging
Expand Down
20 changes: 12 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,18 @@ ignore_imports = [
[tool.ruff]
line-length = 88
show-fixes = true
# select = ["A", "B", "C", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
select = [
"F", # Pyflakes
"E", # Pycodestyle
"W", # Pycodestyle
"F", # Pyflakes
"W", # pycodestyle
"E", # pycodestyle
"I", # isort
"UP", # pyupgrade
"I", # isort
"PL", # Pylint
"PL", # Pylint
]
ignore = ["E501"] # Black take care off line-too-long
unfixable = []
ignore = ["E501"] # Black takes care of line-too-long

[tool.ruff.isort]
known-first-party = ["kedro"]

[tool.ruff.per-file-ignores]
"{tests,docs}/*" = ["PLR2004","PLR0913"]

0 comments on commit 4563a4c

Please sign in to comment.