-
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.
- Loading branch information
1 parent
797b9ba
commit cf269b1
Showing
3 changed files
with
74 additions
and
71 deletions.
There are no files selected for viewing
34 changes: 18 additions & 16 deletions
34
crates/ruff_linter/resources/test/fixtures/pylint/super_without_brackets.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 |
---|---|---|
@@ -1,31 +1,33 @@ | ||
class Soup: | ||
class Animal: | ||
@staticmethod | ||
def temp() -> None: | ||
print("Soup is hot!") | ||
def speak(): | ||
return f"This animal says something." | ||
|
||
|
||
class TomatoSoup(Soup): | ||
class BadDog(Animal): | ||
@staticmethod | ||
def temp() -> None: | ||
super.temp() # PLW0245 | ||
print("But tomato soup is even hotter!") | ||
def speak(): | ||
original_speak = super.speak() # PLW0245 | ||
return f"{original_speak} But as a dog, it barks!" | ||
|
||
class ProperTomatoSoup(Soup): | ||
|
||
class GoodDog(Animal): | ||
@staticmethod | ||
def temp() -> None: | ||
super().temp() # OK | ||
print("But tomato soup is even hotter!") | ||
def speak(): | ||
original_speak = super().speak() # OK | ||
return f"{original_speak} But as a dog, it barks!" | ||
|
||
|
||
class SuperSoup(Soup): | ||
class FineDog(Animal): | ||
@staticmethod | ||
def temp() -> None: | ||
# override the super builtin | ||
def speak(): | ||
super = "super" | ||
super.temp() # OK (according to this rule, at least) | ||
print(f"But super soup is {super}!") | ||
original_speak = super.speak() # OK | ||
return f"{original_speak} But as a dog, it barks!" | ||
|
||
|
||
def super_without_class() -> None: | ||
super.blah() # OK | ||
|
||
|
||
super.blah() # 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
22 changes: 11 additions & 11 deletions
22
...ylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
super_without_brackets.py:10:9: PLW0245 [*] `super` call without parentheses | ||
super_without_brackets.py:10:26: PLW0245 [*] `super` call is missing parentheses | ||
| | ||
8 | @staticmethod | ||
9 | def temp() -> None: | ||
10 | super.temp() # PLW0245 | ||
| ^^^^^ PLW0245 | ||
11 | print("But tomato soup is even hotter!") | ||
9 | def speak(): | ||
10 | original_speak = super.speak() # PLW0245 | ||
| ^^^^^ PLW0245 | ||
11 | return f"{original_speak} But as a dog, it barks!" | ||
| | ||
= help: Add parentheses to `super` call | ||
|
||
ℹ Safe fix | ||
7 7 | class TomatoSoup(Soup): | ||
7 7 | class BadDog(Animal): | ||
8 8 | @staticmethod | ||
9 9 | def temp() -> None: | ||
10 |- super.temp() # PLW0245 | ||
10 |+ super().temp() # PLW0245 | ||
11 11 | print("But tomato soup is even hotter!") | ||
9 9 | def speak(): | ||
10 |- original_speak = super.speak() # PLW0245 | ||
10 |+ original_speak = super().speak() # PLW0245 | ||
11 11 | return f"{original_speak} But as a dog, it barks!" | ||
12 12 | | ||
13 13 | class ProperTomatoSoup(Soup): | ||
13 13 | | ||
|
||
|