feat(linter): ruff integration (#57)

This commit is contained in:
Xuehai Pan 2023-03-15 17:37:42 +08:00 committed by GitHub
parent c5ce570c72
commit 20313d08bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 538 additions and 313 deletions

View file

@ -85,3 +85,79 @@ multi_line_output = 3
[tool.pydocstyle]
convention = "google"
match-dir = '^(?!(gui|callbacks|docs))[^\.].*'
[tool.ruff]
target-version = "py37"
line-length = 100
show-source = true
src = ["nvitop"]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"N", # pep8-naming
"UP", # pyupgrade
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"COM", # flake8-commas
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"ISC", # flake8-implicit-str-concat
"PIE", # flake8-pie
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"RUF", # ruff
]
ignore = [
# E501: line too long
# W505: doc line too long
# too long docstring due to long example blocks
"E501",
"W505",
# ANN101: missing type annotation for `self` in method
# ANN102: missing type annotation for `cls` in classmethod
"ANN101",
"ANN102",
# ANN401: dynamically typed expressions (typing.Any) are disallowed
"ANN401",
# S101: use of `assert` detected
# internal use and may never raise at runtime
"S101",
# SIM105: use `contextlib.suppress(...)` instead of try-except-pass
# reduce unnessary function call
"SIM105",
]
[tool.ruff.per-file-ignores]
"__init__.py" = [
"F401", # unused-import
]
"setup.py" = [
"ANN", # flake8-annotations
]
"nvitop/api/lib*.py" = [
"N", # pep8-naming
"ANN", # flake8-annotations
]
"nvitop/callbacks/*.py" = [
"ANN", # flake8-annotations
]
"nvitop/gui/**/*.py" = [
"ANN", # flake8-annotations
]
[tool.ruff.flake8-annotations]
allow-star-arg-any = true
[tool.ruff.flake8-quotes]
docstring-quotes = "double"
multiline-quotes = "double"
inline-quotes = "single"
[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"