mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
507 B
507 B
unnecessary-generator-set (C401)
Derived from the flake8-comprehensions linter.
Autofix is always available.
What it does
Checks for unnecessary generators that can be rewritten as set
comprehensions.
Why is this bad?
It is unnecessary to use set
around a generator expression, since
there are equivalent comprehensions for these types. Using a
comprehension is clearer and more idiomatic.
Examples
set(f(x) for x in foo)
Use instead:
{f(x) for x in foo}