-
Notifications
You must be signed in to change notification settings - Fork 104
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 to pre-commit (before isort + flake8 to test it as a possible replacement) #490
Changes from 4 commits
e21db50
f015fdd
3aca73e
dbd131e
95f64ea
52cb31b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,16 +108,6 @@ exclude = [ | |
"tests", | ||
] | ||
|
||
[tool.isort] | ||
atomic = true | ||
force_grid_wrap = 0 | ||
include_trailing_comma = true | ||
lines_after_imports = 2 | ||
lines_between_types = 1 | ||
multi_line_output = 3 | ||
use_parentheses = true | ||
known_first_party = "attr" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "-vrsx -n auto" | ||
flake8-max-line-length = 105 | ||
|
@@ -157,3 +147,46 @@ platforms = ["linux-64", "osx-64", "osx-arm64", "win-64", "osx-arm64", "linux-aa | |
# This is necessary to pull in the lockfile/filelock dependency | ||
# since we don't handle the optional dependency. | ||
cachecontrol-with-filecache = ">=0.12.9" | ||
|
||
|
||
[tool.ruff] | ||
target-version = "py38" | ||
ignore = [ | ||
"E501", | ||
"F401", | ||
"F403", | ||
# Disabled during migration to Ruff: | ||
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. Many of these can be enabled and autofixed, but I felt it would be better to tackle it in a separate PR to keep a reasonable scope for this one :) |
||
"A001", | ||
"A002", | ||
"A003", | ||
"C401", | ||
"C405", | ||
"C408", | ||
"C409", | ||
"C413", | ||
"C414", | ||
"C416", | ||
"RUF012", | ||
"RUF015", | ||
] | ||
line-length = 89 | ||
select = [ | ||
"A", # flake8-builtins | ||
# "B", # flake8-bugbear | ||
"B006", # Do not use mutable data structures for argument defaults | ||
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.
|
||
"C4", # flake8-comprehensions | ||
"C9", # mccabe | ||
"E", # pycodestyle errors | ||
"F", # pyflakes | ||
"I", # isort | ||
"RUF", # ruff rules | ||
"W", # pycodestyle warnings | ||
] | ||
|
||
[tool.ruff.mccabe] | ||
max-complexity = 18 | ||
|
||
[tool.ruff.isort] | ||
lines-after-imports = 2 | ||
lines-between-types = 1 | ||
known-first-party = ["attr"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
black | ||
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. If 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. It's still useful to have in the dev environment. If you're running VS Code, then black is a requirement for "Format Document..." (although I'm not 100% sure this is still the case since they came out with the Black VS Code extension.) 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. Also, ruff is a linter, not a type checker, so I think we want to keep mypy, at least for now. 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.
Yes, I was more thinking about mypy being on the slow side to use in a pre-commit workflow, not about eliminating it entirely. I don't want to touch mypy for this PR in any case, one thing at a time is enough for me 😆 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.
Interesting. I'm not a VSCode user, but I assumed that would integrate with pre-commit as well. Makes sense! |
||
check-manifest | ||
doctr | ||
flake8 | ||
flake8-builtins | ||
flake8-comprehensions | ||
flake8-mutable | ||
build | ||
freezegun | ||
isort | ||
mypy | ||
pre_commit | ||
pylint | ||
pytest | ||
pytest-cov | ||
pytest-flake8 | ||
pytest-xdist | ||
pytest-timeout | ||
tomli; python_version<"3.11" | ||
|
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.
Thinking out loud: This is probably safe as-is because this function would only be called one time per CLI invocation. But if that assumption changes, this use of a mutable default value could bite in the future.