-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Implements [`C2801`/`unnecessary-dunder-calls`](https://pylint.readthedocs.io/en/stable/user_guide/messages/convention/unnecessary-dunder-call.html) There are more that this could cover, but the implementations get a little less straightforward and ugly. Might come back to it in a future PR, or someone else can! See: #970 ## Test Plan `cargo test`
- Loading branch information
1 parent
0e20271
commit e3ad163
Showing
10 changed files
with
849 additions
and
138 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
crates/ruff_linter/resources/test/fixtures/pylint/unnecessary_dunder_call.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Any | ||
|
||
|
||
print((3.0).__add__(4.0)) # PLC2801 | ||
print((3.0).__sub__(4.0)) # PLC2801 | ||
print((3.0).__mul__(4.0)) # PLC2801 | ||
print((3.0).__truediv__(4.0)) # PLC2801 | ||
print((3.0).__floordiv__(4.0)) # PLC2801 | ||
print((3.0).__mod__(4.0)) # PLC2801 | ||
print((3.0).__eq__(4.0)) # PLC2801 | ||
print((3.0).__ne__(4.0)) # PLC2801 | ||
print((3.0).__lt__(4.0)) # PLC2801 | ||
print((3.0).__le__(4.0)) # PLC2801 | ||
print((3.0).__gt__(4.0)) # PLC2801 | ||
print((3.0).__ge__(4.0)) # PLC2801 | ||
print((3.0).__str__()) # PLC2801 | ||
print((3.0).__repr__()) # PLC2801 | ||
print([1, 2, 3].__len__()) # PLC2801 | ||
print((1).__neg__()) # PLC2801 | ||
|
||
|
||
class Thing: | ||
def __init__(self, stuff: Any) -> None: | ||
super().__init__() # OK | ||
super().__class__(stuff=(1, 2, 3)) # OK | ||
|
||
|
||
blah = lambda: {"a": 1}.__delitem__("a") # OK | ||
|
||
blah = dict[{"a": 1}.__delitem__("a")] # OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.