[flake8-pyi] Implement PYI064#11325
Conversation
| w1: Final[Literal[123]] # PYI064 | ||
|
|
||
| # This should be fixable, but marked as unsafe | ||
| w2: Final[Literal[123]] = "random value" # PYI064 |
There was a problem hiding this comment.
I think an unsafe autofix is appropriate here (specifically when the assignment value is different from the literal value).
Is autofixing it to w2: Final = 123 in unsafe mode fair?
There was a problem hiding this comment.
ummmmmmm this kind of thing doesn't really make any sense, right? I think I'd lean towards not doing an autofix here -- "refuse the temptation to guess"
|
|
|
||
| // Discards tuples like `Literal[1, 2, 3]` | ||
| // and complex literals like `Literal[{1, 2}]` | ||
| if !matches!( |
There was a problem hiding this comment.
can potentially be moved to ruff_python_ast/src/helpers.rs, as a is_literal_expr helper.
| PlatformName = Literal["linux", "macos", "windows"] | ||
| PLATFORMS: Final[set[PlatformName]] = {"linux", "macos", "windows"} # No issue here | ||
|
|
||
| foo: Final[{1, 2, 3}] = {1, 2, 3} # No issue here |
There was a problem hiding this comment.
Right now this mimics flake8-pyi behaviour, however I think raising the issue here should be fine?
|
@AlexWaygood -- will follow-up and merge this. |
flake8-pyi] Implement PYI064
Summary
Implements
Y064fromflake8-pyiand its autofix.Test Plan
cargo test/cargo insta review