Skip to content

PLW0642 flags inplace operators called on self #12954

@Skylion007

Description

@Skylion007
ruff check --select="PLW0642"
    def symmetric_difference_update(self, other: Iterable[T]) -> None:
         self ^= other  # type: ignore[operator, arg-type]

is errantly flagged by PLW0642, but I am in these case I'm calling an overloaded function operator.ixor on self, not trying to assign a new variable to it. The former would have an actual side affect here, while the later would not affect it at all (which this bug is trying to catch).

In this case, other is a set, and I can update typing if that the typing is what is confusing ruff, but I wanted to
version: ruff 0.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementationbugSomething isn't workinghelp wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions