You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this oddity. The suggested fix for C401 actually results in C416 because i isn't transformed in any way. Is there a better way to indicate this in the error message?
$ poetry run ruff check --output-format full test.py
test.py:1:6: C401 Unnecessary generator (rewrite as a `set` comprehension)
|
1 | _a = set(i for i in range(10))
| ^^^^^^^^^^^^^^^^^^^^^^^^^ C401
2 | _b = {i for i in range(10)}
3 | _c = set(range(10))
|
= help: Rewrite as a `set` comprehension
test.py:2:6: C416 Unnecessary `set` comprehension (rewrite using `set()`)
|
1 | _a = set(i for i in range(10))
2 | _b = {i for i in range(10)}
| ^^^^^^^^^^^^^^^^^^^^^^ C416
3 | _c = set(range(10))
|
= help: Rewrite using `set()`
Found 2 errors.
No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
$ poetry run ruff --version
ruff 0.2.2
The text was updated successfully, but these errors were encountered:
…matches `C416` (#10596)
## Summary
<!-- What's the purpose of the change? What does it do, and why? -->
Similar to #10419, there was a case where there is a collision of C401
and C416 (as discussed in #10101).
Fixed this by implementing short-circuit for the comprehension of the
form `{x for x in foo}`.
## Test Plan
<!-- How was it tested? -->
Extended `C401.py` with the case where `set` is not builtin function,
and divided the case where the short-circuit should occur.
Removed the last testcase of `print(f"{ {set(a for a in 'abc')} }")`
test as this is invalid as a python code, but should I keep this?
I ran into this oddity. The suggested fix for
C401
actually results inC416
becausei
isn't transformed in any way. Is there a better way to indicate this in the error message?The text was updated successfully, but these errors were encountered: