Add known limitation to C416 with dictionaries#13627
Conversation
|
crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs
Outdated
Show resolved
Hide resolved
C416 with tuple keysC416 with dictionaries
crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs
Outdated
Show resolved
Hide resolved
| /// When the comprehension iterates over a sequence, the fix is correct. However, Ruff cannot | ||
| /// consistently infer if the iterable type is a sequence or a mapping. |
There was a problem hiding this comment.
It's not really just the autofix that's incorrect in these cases: the message and suggestion of the rule's diagnostic is also incorrect in these cases
| /// When the comprehension iterates over a sequence, the fix is correct. However, Ruff cannot | |
| /// consistently infer if the iterable type is a sequence or a mapping. | |
| /// When the comprehension iterates over a sequence, the rule's suggestion is correct. | |
| /// However, Ruff cannot consistently infer if the iterable type is a sequence or a mapping. |
There was a problem hiding this comment.
I mean, it should be dict(iterable.keys()) right? I think the rule is correct and just the fix is wrong?
|
I think we should try to improve C416 before it's stabilized, so it's not wrong so often. The fix could be safe for non-dict comprehensions if we don't mind dropping some comments. |
|
The policy I've been using for the minor releases I've been shepherding has been not to stabilise any rules that have significant open issues on the tracker |
Part of #13625
See also #13629