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

[pylint] Fix missing parens in unsafe fix for unnecessary-dunder-call (PLC2801) #15762

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
# Calls
print(a.__call__()) # PLC2801 (no fix, intentional)

class Foo:
def __init__(self, v):
self.v = v

def __add__(self, other):
self.v += other
return self

def get_v(self):
return self.v

foo = Foo(1)
foo.__add__(2).get_v() # PLC2801


# Lambda expressions
blah = lambda: a.__add__(1) # PLC2801

Expand All @@ -72,13 +87,22 @@

# Subscripts
print({"a": a.__add__(1)}["a"]) # PLC2801
# https://github.com/astral-sh/ruff/issues/15745
print("x".__add__("y")[0]) # PLC2801

# Starred
print(*[a.__add__(1)]) # PLC2801

list1 = [1, 2, 3]
list2 = [4, 5, 6]
print([*list1.__add__(list2)]) # PLC2801

# Slices
print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801

# Attribute access
# https://github.com/astral-sh/ruff/issues/15745
print(1j.__add__(1.0).real) # PLC2801

class Thing:
def __init__(self, stuff: Any) -> None:
Expand Down
Loading
Loading