-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
The fix for post-init-default (RUF033) introduces a syntax error when it removes necessary parentheses from around the default expression.
$ cat >ruf033_1.py <<'# EOF'
from dataclasses import dataclass
@dataclass
class Foo:
def __post_init__(self, bar: int = (x := 1)) -> None:
pass
# EOF
$ ruff check --isolated ruf033_1.py --select RUF033 --unsafe-fixes --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.$ cat >ruf033_2.py <<'# EOF'
from dataclasses import dataclass
@dataclass
class Foo:
def __post_init__(self, bar: int = (-
1
)) -> None:
pass
# EOF
$ ruff check --isolated ruf033_2.py --select RUF033 --unsafe-fixes --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.Version
ruff 0.12.0 (87f0feb 2025-06-17)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome