Skip to content
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

Merged
merged 5 commits into from
Jan 12, 2025
Merged

Switch to ruff for linting #488

merged 5 commits into from
Jan 12, 2025

Conversation

zerolab
Copy link
Contributor

@zerolab zerolab commented Dec 17, 2024

Builds on #486 and switched the Python linting to Ruff

@zerolab zerolab changed the title Chore/switch to ruff Switch to ruff for linting Dec 17, 2024
Base automatically changed from chore/django-5.1 to main December 18, 2024 22:19
Comment on lines +5 to +16
"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
Copy link
Member

@Stormheg Stormheg Dec 18, 2024

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 ❤️

Copy link
Member

@Stormheg Stormheg left a 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.

Comment on lines 4 to 9
from django.db import migrations, models

import wagtail.blocks
import wagtail.fields

from django.db import migrations, models


Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

@zerolab zerolab Dec 19, 2024

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

Copy link
Member

@Stormheg Stormheg left a 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 👍

@Stormheg Stormheg merged commit 930d3d7 into main Jan 12, 2025
3 checks passed
@Stormheg Stormheg deleted the chore/switch-to-ruff branch January 12, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants