-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Minor optimizations by using comprehensions #2771
Conversation
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 lint job seems to have failed with other errors on this PR, so a commit fixing all those will also be needed
Are you talking about #2773 or something else? |
I'm talking about this fail: https://github.com/pygame-community/pygame-ce/actions/runs/8425378679/job/23088593026 |
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.
LGTM, thanks for the PR 🥳
This PR now has merge conflicts. |
764833b
to
9d48251
Compare
Git conflicts fixed. |
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.
LGTM, thanks!
%
pipx install ruff
%
ruff check --select=C4,PERF --statistics
%
ruff check --select=C4,PERF --fix --unsafe-fixes
%
ruff rule C408
unnecessary-collection-call (C408)
Derived from the flake8-comprehensions linter.
Fix is always available.
What it does
Checks for unnecessary
dict
,list
ortuple
calls that can berewritten as empty literals.
Why is this bad?
It's unnecessary to call, e.g.,
dict()
as opposed to using an emptyliteral (
{}
). The former is slower because the namedict
must belooked up in the global scope in case it has been rebound.
Examples
Use instead:
Fix safety
This rule's fix is marked as unsafe, as it may occasionally drop comments
when rewriting the call. In most cases, though, comments will be preserved.
Options
lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments