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

Pre-commit: Add Python linter Ruff #778

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 30, 2024

@@ -24,8 +24,8 @@ class TaskSelectWidget(Select):

def tasks_as_choices(self):
_ = self._modules
tasks = list(sorted(name for name in self.celery_app.tasks
if not name.startswith('celery.')))
tasks = sorted(name for name in self.celery_app.tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully sure about this change

Copy link
Contributor Author

@cclauss cclauss Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unnecessary to use list() around sorted(), as the latter already returns a list.

Running the following on the commandline...

% pipx run ruff rule C413

unnecessary-call-around-sorted (C413)

Derived from the flake8-comprehensions linter.

Fix is always available.

What it does

Checks for unnecessary list or reversed calls around sorted
calls.

Why is this bad?

It is unnecessary to use list around sorted, as the latter already
returns a list.

[ ... ]

@cclauss cclauss requested a review from auvipy July 31, 2024 08:41
@cclauss cclauss requested review from thedrow and Nusnus August 2, 2024 11:33
@cclauss cclauss merged commit a87c9f6 into celery:main Aug 7, 2024
24 checks passed
@cclauss cclauss deleted the add-ruff-to-pre-commit branch August 7, 2024 21:28
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