unnecessary-collection-call
What it does
Section titled “What it does”Reports dict(), list() or tuple() with no arguments, and dict(a=1) with only keyword arguments.
Why it matters
Section titled “Why it matters”A literal ({}, [], (), {"a": 1}) says the same, needs no name lookup and call, and is faster.
To fix, write the literal.
Example
Section titled “Example”...pprint(3)x = dict()x = dict(a=1)x = dict(**a)x = dict(a, b=1)x = list()x = tuple()x = list(a)...Configuration
Section titled “Configuration”python: lint: rules: unnecessary-collection-call: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line unnecessary-collection-call in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | C408 |
full |