-
Notifications
You must be signed in to change notification settings - Fork 66
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
Switch to ruff for linting #488
Conversation
"B", # flake8-bugbear | ||
"BLE", # flake8-blind-except | ||
"C4", # flake8-comprehensions | ||
"DJ", # flake8-django | ||
"E", # pycodestyle errors | ||
"F", # pyflakes | ||
"I", # isort | ||
"INT", # flake8-gettext | ||
"PIE", # flake8-pie | ||
"PGH", # pygrep-hooks | ||
"S", # flake8-bandit | ||
"SIM", # flake8-simplify |
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.
Most of these I had never heard of but solve things that semi-regularly come up in code reviews I perform.
I certainly will be adopting this ruff config ❤️
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.
@zerolab looks good but have one question/suggestion.
from django.db import migrations, models | ||
|
||
import wagtail.blocks | ||
import wagtail.fields | ||
|
||
from django.db import migrations, models | ||
|
||
|
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.
@zerolab this change looks a bit strange to me - I assume this happens because import x
takes precedence over from x import y
. I would prefer third-party imports stay in alphabetical order.
Is this intentional behavior by ruff or is this something we can have an opinion about?
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.
it is a ruff opinion. will have a look tommorrow whether we can influence that
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 best I could get it to is:
- import django.db.models.deletion
from django.db import migrations, models
+ import django.db.models.deletion
import wagtail.blocks
import wagtail.fields
using https://docs.astral.sh/ruff/settings/#lint_isort_force-sort-within-sections
this halved the number of changed files
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.
That's acceptable to me 👍
Builds on #486 and switched the Python linting to Ruff