Skip to content

Commit

Permalink
Add ruff rules, pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed May 20, 2024
1 parent d3abd5d commit c446575
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 39 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ debian/tmp/
dist/*
doc/*
*.pyc
debian/python-rtslib.substvars
debian/rtslib-doc.debhelper.log
debian/tmp/
venv/
.idea
*egg-info/
*egg-info/
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-ast
- id: check-docstring-first
- id: check-case-conflict
- id: check-merge-conflict
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
1 change: 0 additions & 1 deletion COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,3 @@
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

65 changes: 32 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.12",
"Operating System :: POSIX :: Linux",
]
dependencies = [
"pyudev >= 0.16.1",
"pyudev ~= 0.18",
]
dynamic = ["version"]

Expand All @@ -47,42 +48,40 @@ select = [
"F", # Pyflakes
"E", # pycodestyle error
"W", # pycodestyle warning
# "I", # isort
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
# "YTT", # flake8-2020
# "S", # flake8-bandit
"YTT", # flake8-2020
"S", # flake8-bandit
"B", # flake8-bugbear
# "A", # flake8-builtins
# "COM", # flake8-commas
# "C4", # flake8-comprehensions
# "EXE", # flake8-executable
# "FA", # flake8-future-annotations
# "ISC", # flake8-implicit-str-concat
# "ICN", # flake8-import-conventions
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
# "Q003", # flake8-quotes avoidable-escaped-quote
# "Q004", # flake8-quotes unnecessary-escaped-quote
# "RSE", # flake8-raise
# "RET", # flake8-return
# "SIM", # flake8-simplify
# "TID", # flake8-tidy-imports
# "INT", # flake8-gettext
# "ARG", # flake8-unused-argument
# #"PTH", # flake8-use-pathlib TODO
"Q003", # flake8-quotes avoidable-escaped-quote
"Q004", # flake8-quotes unnecessary-escaped-quote
"RSE", # flake8-raise
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"INT", # flake8-gettext
"ARG", # flake8-unused-argument
"PTH", # flake8-use-pathlib
"PL", # Pylint
# "FLY", # flynt
# "PERF", # Perflint
# "FURB", # refurb
# "RUF", # Ruff
"FLY", # flynt
"PERF", # Perflint
"FURB", # refurb
"RUF", # Ruff
]
ignore = [
"E722", # TODO do not use bare 'except'
"B904", # raise-without-from-inside-except
# "S104", # Possible binding to all interfaces (0.0.0.0)
# "RUF012", # TODO Mutable class attributes should be annotated with `typing.ClassVar`
# "B904", # raise-without-from-inside-except
# "ARG002", "PLR6301", # TODO Unused self, parameter in methods definitions
# "PLR09", # Too many branches/statements/arguments
# "PLW1514", # TODO `open` in text mode without explicit `encoding` argument
]
"E722", # TODO do not use bare 'except'
"B904", # TODO raise-without-from-inside-except
"PERF203", # TODO `try`-`except` within a loop incurs performance overhead
"PLR09", # Too many branches/statements/arguments
]
[tool.ruff.lint.per-file-ignores]
# Magic value used in comparison
"scripts/targetctl" = ["PLR2004"]
1 change: 0 additions & 1 deletion scripts/convert-to-json
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,3 @@ with Path("/etc/target/scsi_target.lio").open as f:
output = {'storage_objects': sos, 'fabric_modules': fabs, 'targets': targs}

print(json.dumps(output, indent=2, sort_keys=True))

1 change: 0 additions & 1 deletion systemd/target.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ SyslogIdentifier=target

[Install]
WantedBy=multi-user.target

0 comments on commit c446575

Please sign in to comment.