-
Notifications
You must be signed in to change notification settings - Fork 7k
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
RUFF C408 rule (unnecessary-collection-call) #6316
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: bigcat88 <[email protected]>
Signed-off-by: bigcat88 <[email protected]>
@comfyanonymous should I open a PRs for multiple-starts-ends-with (PIE810) or/and unnecessary-range-start (PIE808) rules, after merge of this one? They are both will be small, without many edits. |
# Conflicts: # ruff.toml
just a friendly note: This PR is rebased and ready. If it is not needed, please close it. |
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.
👌
This rule checks for unnecessary
dict()
,list()
ortuple()
calls that can be rewritten as empty literals.Why is this bad?
It's unnecessary to call, e.g.,
dict()
as opposed to using an empty literal ({}
). The former is slower because the name dict must be looked up in the global scope in case it has been rebound.Examples:
Use instead:
Ruff's docs link