-
-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ruff rules A,B,C4,EM,ISC,PERF,PGH,RET,RUF,S,SIM,SLF #549
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,26 +71,38 @@ target-version = "py38" | |
|
||
[tool.ruff.lint] | ||
select = [ | ||
"A", # flake8-builtins | ||
"AIR", # Airflow | ||
"ASYNC", # flake8-async | ||
"B", # flake8-bugbear | ||
"BLE", # flake8-blind-except | ||
"C4", # flake8-comprehensions | ||
"C90", # McCabe cyclomatic complexity | ||
"DJ", # flake8-django | ||
"DTZ", # flake8-datetimez | ||
"E", # pycodestyle errors | ||
"EM", # flake8-errmsg | ||
"F", # Pyflakes | ||
"FIX", # flake8-fixme | ||
"FLY", # flynt | ||
"G", # flake8-logging-format | ||
"ICN", # flake8-import-conventions | ||
"INP", # flake8-no-pep420 | ||
"INT", # flake8-gettext | ||
"ISC", # flake8-implicit-str-concat | ||
"NPY", # NumPy-specific rules | ||
"PD", # pandas-vet | ||
"PERF", # Perflint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perflint describes itself as "This project is an early beta. It will likely raise many false-positives in your code" - you have previously said that you think any and all passing lints should be included - more is necessarily better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pull request did not make any PERF-related changes (other than enabling PERF). When I read the Why is this bad? section of these rule I see quantified performance gains. Here we are not running If you would like, we can disable the PERF rules. |
||
"PGH", # pygrep-hooks | ||
"PIE", # flake8-pie | ||
"PL", # Pylint | ||
"PYI", # flake8-pyi | ||
"RET", # flake8-return | ||
"RSE", # flake8-raise | ||
"RUF", # Ruff-specific rules | ||
"S", # flake8-bandit | ||
"SIM", # flake8-simplify | ||
"SLF", # flake8-self | ||
"SLOT", # flake8-slots | ||
"T10", # flake8-debugger | ||
"T20", # flake8-print | ||
|
@@ -99,32 +111,20 @@ select = [ | |
"UP", # pyupgrade | ||
"W", # pycodestyle warnings | ||
"YTT", # flake8-2020 | ||
# "A", # flake8-builtins | ||
# "ANN", # flake8-annotations | ||
# "ARG", # flake8-unused-arguments | ||
# "B", # flake8-bugbear | ||
# "C4", # flake8-comprehensions | ||
# "COM", # flake8-commas | ||
# "CPY", # flake8-copyright | ||
# "CPY", # flake8-copyright | ||
# "D", # pydocstyle | ||
# "EM", # flake8-errmsg | ||
# "ERA", # eradicate | ||
# "EXE", # flake8-executable | ||
# "FA", # flake8-future-annotations | ||
# "FBT", # flake8-boolean-trap | ||
# "I", # isort | ||
# "ISC", # flake8-implicit-str-concat | ||
# "N", # pep8-naming | ||
# "PERF", # Perflint | ||
# "PGH", # pygrep-hooks | ||
# "PT", # flake8-pytest-style | ||
# "PTH", # flake8-use-pathlib | ||
# "Q", # flake8-quotes | ||
# "RET", # flake8-return | ||
# "RUF", # Ruff-specific rules | ||
# "S", # flake8-bandit | ||
# "SIM", # flake8-simplify | ||
# "SLF", # flake8-self | ||
# "TCH", # flake8-type-checking | ||
# "TRY", # tryceratops | ||
] | ||
|
@@ -135,14 +135,20 @@ exclude = [ | |
"*/migrations/*", | ||
"docs", | ||
] | ||
ignore = ["F401"] | ||
ignore = [ | ||
"F401", # Imported but unused | ||
"ISC002", # Implicit string concatenation may conflict with black and ruff format | ||
"S101", # Use of assert detected | ||
] | ||
|
||
[tool.ruff.lint.mccabe] | ||
max-complexity = 23 | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"docs/conf.py" = ["INP001"] | ||
"test_app/models.py" = ["DJ008"] # FIXME | ||
"waffle/admin.py" = ["SLF001"] # FIXME | ||
"waffle/jinja.py" = [ "PGH003" ] # FIXME | ||
"waffle/models.py" = ["DJ012", "PYI019"] # FIXME | ||
|
||
[tool.ruff.lint.pylint] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above lints look useful to me in that the changes made to make the lints pass mostly look like useful improvements. The possible exception to my mind is defining a
msg
variable before raising the exception - I am ambivalent to that one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%
ruff rule EM101
If you would like, we can revert the EM transformations.
%
ruff check --select=EM--statistics