ruff
1079975b - [`ruff`] Fix `RUF033` breaking with named default expressions (#19115)

Commit
142 days ago
[`ruff`] Fix `RUF033` breaking with named default expressions (#19115) ## Summary The generated fix for `RUF033` would cause a syntax error for named expressions as parameter defaults. ```python from dataclasses import InitVar, dataclass @dataclass class Foo: def __post_init__(self, bar: int = (x := 1)) -> None: pass ``` would be turned into ```python from dataclasses import InitVar, dataclass @dataclass class Foo: x: InitVar[int] = x := 1 def __post_init__(self, bar: int = (x := 1)) -> None: pass ``` instead of the syntactically correct ```python # ... x: InitVar[int] = (x := 1) # ... ``` ## Test Plan Test reproducer (plus some extra tests) have been added to the test suite. ## Related Fixes: https://github.com/astral-sh/ruff/issues/18950
Author
Parents
Loading