Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLW0642 flags inplace operators called on self #12954

Closed
Skylion007 opened this issue Aug 17, 2024 · 3 comments · Fixed by #12957
Closed

PLW0642 flags inplace operators called on self #12954

Skylion007 opened this issue Aug 17, 2024 · 3 comments · Fixed by #12957
Labels
accepted Ready for implementation bug Something isn't working help wanted Contributions especially welcome rule Implementing or modifying a lint rule

Comments

@Skylion007
Copy link
Contributor

Skylion007 commented Aug 17, 2024

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

@AlexWaygood
Copy link
Member

It makes sense to me to exclude augmented assignments from this rule, and it would also mean we'd have more similar behaviour to pylint here. (Pylint seems to ignore augmented assignments for their version of this rule -- though they also ignore annotated assignments, which makes less sense to me.)

@diceroll123 -- was there a specific reason you decided to differ from pylint's behaviour here when you added this rule in #9267? :-)

@AlexWaygood AlexWaygood added the rule Implementing or modifying a lint rule label Aug 17, 2024
@diceroll123
Copy link
Contributor

Oversight on my part.

Is the desire to remove augmented assignments and keep annotated? 😄

@AlexWaygood
Copy link
Member

Is the desire to remove augmented assignments and keep annotated? 😄

Yeah, I think so!

@AlexWaygood AlexWaygood added bug Something isn't working accepted Ready for implementation help wanted Contributions especially welcome labels Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working help wanted Contributions especially welcome rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants