-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Tested with ruff 0.11.8
Consider this (contrived) case of comments appearing in a dictionary definition:
from dataclasses import dataclass
@dataclass
class Moo:
x: float
y: float
Moo(**{
# Interesting observation about x
"x": 1.0,
# Interesting observation about y
"y": 2.0
})applying autofix for PIE804 (which is not marked unsafe) gives the following:
from dataclasses import dataclass
@dataclass
class Moo:
x: float
y: float
Moo(x=1.0, y=2.0)which has dropped the comment.
Ideally I think the comments should be preserved, but otherwise perhaps this autofix should be marked as unsafe?
I came across this in the wild where previously some code constructed a big dictionary, and I was then porting it into a dataclass.. so was using the PIE804 autofix as above to save some typing. But then discovered that the comments got thrown away.
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