Skip to content

Commit

Permalink
Add ruff
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Jun 17, 2024
1 parent ba4933e commit 01aa1ae
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 16 deletions.
21 changes: 5 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,13 @@ repos:
hooks:
- id: autopep8

- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: "6.0.0"
hooks:
- id: flake8
- id: ruff
args:
- --max-line-length=99
files: >
(?x)^(
bin/.*|
examples/.*|
fmf/.*|
tests/.*
)$
- '--fix'
- '--show-fixes'

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
Expand Down
132 changes: 132 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,135 @@ in-place = true
recursive = true
hang-closing = true
aggressive = 2

[tool.ruff]
line-length = 99
src = ["fmf", "tests"]
target-version = "py39"
lint.select = [
"F", # pyflakes
"E", # pycodestyle
"W", # pycodestyle
"I", # isort
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"YTT", # flake8-2020
"PT", # flake8-pytest-style
"RET", # flake8-return
"SIM", # flake8-simplify
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EXE", # flake8-executable
"PIE", # flake8-pie
"RSE", # flake8-raise
"PGH", # pygrep-hooks
"PLC", # pylint-convention
"PLE", # pylint-error
"PLR01", # pylint-refactor
"PLR02",
"PLR04",
"PLR1",
"RUF", # ruff
"D", # pydocstyle
]
lint.ignore = [
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ...
"COM812", # Trailing comma missing
# tmt codebase uses `warn` by default - disabling the check, switching to
# `warning` can be done in an extra patch.
"G010", # `warn` is deprecated in favor of `warning`
"PIE790", # Unnecessary `pass` statement
"PLC1901", # `{}` can be simplified to `{}` as an empty string is falsey
"PLE1205", # Too many arguments for `logging` format string
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`

# pydocstyle
# TODO: the permanent list (drop this comment once the temporary list
# below gets to zero items...)
"D203", # 1 blank line required before class docstring
# TODO: the temporary list - some of these will be enabled in their
# own patches
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D106", # Missing docstring in public nested class
"D107", # Missing docstring in __init__
"D202", # No blank lines allowed after function docstring
"D205", # 1 blank line required between summary line and description
"D210", # No whitespaces allowed surrounding docstring text
"D212", # Multi-line docstring summary should start at the first line
"D301", # Use r""" if any backslashes in a docstring
"D400", # First line should end with a period
"D401", # First line of docstring should be in imperative mood
"D415", # First line should end with a period, question mark, or exclamation point
# To review
"B007",
"B015",
"B018",
"C403",
"C405",
"C408",
"C409",
"C419",
"E721",
"N818",
"PGH004",
"PT009",
"PT011",
"PT012",
"PT027",
"RET505",
"RET507",
"RUF005",
"RUF017",
"SIM105",
"SIM108",
"SIM117",
"UP006",
"UP008",
"UP028",
"UP029",
"UP030",
"UP031",
"UP035",
# Auto-fixable
"D204",
"F401",
"I001",
"PLR0402",
"PT001",
"PT023",
"RSE102",
"RUF010",
"RUF100",
"UP003",
"UP009",
"UP020",
"UP024",
"UP024",
"UP025",
"UP032",
]

[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = ["tmt.utils.field"]

[tool.ruff.lint.pydocstyle]
# "The PEP 257 convention includes all D errors apart from: D203, D212,
# D213, D214, D215, D404, D405, D406, D407, D408, D409, D410, D411, D413,
# D415, D416, and D417."
#
# See https://docs.astral.sh/ruff/faq/#does-ruff-support-numpy-or-google-style-docstrings for
# the most up-to-date info.
convention = "pep257"

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

0 comments on commit 01aa1ae

Please sign in to comment.