-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use ruff for linting #347
Use ruff for linting #347
Conversation
Thanks for the PR! I like the proposed changes. In addition, can you make sure that we enable the same ruff tests as were enabled previously via the other tools? And then remove the other tools? |
Hi @jendrikseipp, this PR is ready for review. There are a few things to consider:
|
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.
Thanks for revising the PR! I have a few more nitpicks, but I like where this is going :-)
I see the differences between ruff and black as an advantage for ruff. So if you like, it would be great if you could change the formatter to ruff in a separate PR later.
Also, feel free to replace the "tox -e style" and "tox -e fix-style" commands with pre-commit in another PR.
Great stuff!
pyproject.toml
Outdated
target-version = "py38" | ||
|
||
[tool.ruff.lint] | ||
select = ["E4", "E7", "E9", "F", "B", "C4", "UP", "W", "C901"] |
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.
Please add a comment telling which checks are enabled by ruff by default.
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.
Also, please add short comments on what these letters mean. For both of these changes, it's probably best to convert the list to have one entry per line, with a brief comment next to it.
pyproject.toml
Outdated
select = ["E4", "E7", "E9", "F", "B", "C4", "UP", "W", "C901"] | ||
ignore = [ | ||
# C408: unnecessary dict call | ||
"C408", |
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.
"C408", | |
"C408", # unnecessary dict call |
(use one line)
vulture/core.py
Outdated
@@ -256,7 +256,7 @@ def handle_syntax_error(e): | |||
except SyntaxError as err: | |||
handle_syntax_error(err) | |||
|
|||
def scavenge(self, paths, exclude=None): | |||
def scavenge(self, paths, exclude=None): # noqa: C901 |
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.
Let's just remove C901 from the list of selected tests instead.
tox.ini
Outdated
|
||
[testenv:fix-style] | ||
basepython = python3 | ||
deps = | ||
black==22.3.0 | ||
pyupgrade==2.28.0 | ||
ruff==0.1.13 | ||
allowlist_externals = | ||
bash |
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 bash special case is obsolete now. Same in the "style" part above.
.github/workflows/pre-commit.yml
Outdated
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/setup-python@v5 |
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.
Is it necessary to set up a Python version here? The ubuntu-latest image already comes with Python installed.
@jendrikseipp I updated the code according to your review. Can you take a look again, please? The list of patterns ignored by Noted about the future improvement of |
Great, thanks! In an upcoming PR, please add a changelog entry for this and the other planned changes. And feel free to add your name or nick to the changelog entry. |
Description
Hello,
This MR configures ruff, an extremely fast Python linter and code formatter to
vulture
.ruff
can potentially replace all the current linting and formatting tools, namelyblack
,flake8
andpyupgrade
.The current config in
pyproject.toml
is the default one, I put it there for ease of your review and customization.Let me know if this change is welcome. I can make further adjustments to the config to suit
vulture
style if needed.Checklist:
tox -e fix-style
to format my code and checked the result withtox -e style
.