Skip to content

PIE794 false positive when mutating class variable. Also leads to a bad fix. #8497

@Skylion007

Description

@Skylion007
class Person:
    name = "Foo"
    name = name + " Bar"

with unsafe fixes applied becomes:

class Person:
    name = "Foo"

It may not be the cleanest way of writing that, but it probably shouldn't trigger.

class Person:
    names = ["Foo"]
    names = names + ["Bar"]

is a use case I've actually seen in real code that probably should not be flagged.

ruff version is 0.1.4.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions