Skip to content

Commit

Permalink
Migrate to using ruff as a formatter.
Browse files Browse the repository at this point in the history
  - Adhere to advice from ruff developers for formatting rules.
  - Make `tox -e lint` validate/check-only.
  - Add `tox -e lint-fix` to format and fix linting where possible.
  • Loading branch information
terjekv committed Dec 8, 2023
1 parent 3c7600a commit ee81f5c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ ignore = [
"D213",
# ANN101 (Missing type annotation for `self` in method) is infered.
"ANN101",

# Rules disabled due to using ruff as a formatter. Most of these rules
# will thus be enforced by the formatter.
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191", # Indentation contains tabs
"E111", # Indentation is not a multiple of four
"E114", # Indentation is not a multiple of four (comment)
"E117", # Over-indented
"D206", # Docstring should be indented with spaces, not tabs
"D300", # Use """triple double quotes""" (found '''-quotes)
"Q000", # Remove bad quotes (inlined)
"Q001", # Remove bad quotes (multiline)
"Q002", # Remove bad quotes (docstring)
"Q003", # Avoidable escape quote
"COM812", # Missing trailing comma in Python 3.6+
"COM819", # Prohibited trailing comma
"ISC001", # Implicit string concatenation (single line)
"ISC002", # Implicit string concatenation (multiline)
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
Expand Down
13 changes: 11 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ python =

[testenv:lint]
skip_install = true
description = Invoke ruff on the project.
description = Invoke ruff on the project, fail if non-conformant
allowlist_externals =
ruff
commands =
ruff check --fix mreg_cli
ruff check mreg_cli
ruff format --check mreg_cli

[testenv:lint-fix]
skip_install = true
description = Invoke ruff on the project, fix what can be fixed.
allowlist_externals =
ruff
commands =
ruff check --fix mreg_cli
ruff format mreg_cli

0 comments on commit ee81f5c

Please sign in to comment.