-
-
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.
Create new error arguments-renamed (#4467)
* Create new error arguments-renamed This commits creates the new error arguments-renamed based on the functionality added on #4422 and the changes of #4456. * Merge test files for arguments-differ This commit merges the two kinds of test files that existed for the arguments-differ error, since now all tests run in Python3. * Add tests for arguments-renamed error * Add new error arguments-renamed Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
18ef7ba
commit d150e39
Showing
10 changed files
with
175 additions
and
74 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,74 @@ | ||
#pylint: disable = unused-argument, missing-docstring, no-self-use, line-too-long, useless-object-inheritance, too-few-public-methods | ||
import enum | ||
|
||
|
||
class Condiment(enum.Enum): | ||
CINAMON = 1 | ||
SUGAR = 2 | ||
|
||
class Fruit: | ||
def brew(self, fruit_name: str): | ||
print(f"Brewing a fruit named {fruit_name}") | ||
|
||
def eat_with_condiment(self, fruit_name:str, condiment: Condiment): | ||
print(f"Eating a fruit named {fruit_name} with {condiment}") | ||
|
||
class Orange(Fruit): | ||
def brew(self, orange_name: str): # [arguments-renamed] | ||
print(f"Brewing an orange named {orange_name}") | ||
|
||
def eat_with_condiment(self, orange_name: str, condiment: Condiment()): #[arguments-renamed] | ||
print(f"Eating a fruit named {orange_name} with {condiment}") | ||
|
||
class Banana(Fruit): | ||
def brew(self, fruit_name: bool): # No warning here | ||
print(f"Brewing a banana named {fruit_name}") | ||
|
||
def eat_with_condiment(self, fruit_name: str, condiment: Condiment, error: str): # [arguments-differ] | ||
print(f"Eating a fruit named {fruit_name} with {condiment}") | ||
|
||
class Parent(object): | ||
|
||
def test(self, arg): | ||
return arg + 1 | ||
|
||
def kwargs_test(self, arg, *, var1, var2): | ||
print(f"keyword parameters are {var1} and {var2}.") | ||
|
||
class Child(Parent): | ||
|
||
def test(self, arg1): # [arguments-renamed] | ||
return arg1 + 1 | ||
|
||
def kwargs_test(self, arg, *, value1, var2): #[arguments-renamed] | ||
print(f"keyword parameters are {value1} and {var2}.") | ||
|
||
class Child2(Parent): | ||
|
||
def test(self, var): # [arguments-renamed] | ||
return var + 1 | ||
|
||
def kwargs_test(self, *, var1, kw2): #[arguments-renamed, arguments-differ] | ||
print(f"keyword parameters are {var1} and {kw2}.") | ||
|
||
class ParentDefaults(object): | ||
|
||
def test1(self, arg, barg): | ||
print(f"Argument values are {arg} and {barg}") | ||
|
||
def test2(self, arg, barg): | ||
print(f"Argument values are {arg} and {barg}!") | ||
|
||
def test3(self, arg1, arg2): | ||
print(f"arguments: {arg1} {arg2}") | ||
|
||
class ChildDefaults(ParentDefaults): | ||
|
||
def test1(self, arg, param2): # [arguments-renamed] | ||
print(f"Argument values are {arg} and {param2}") | ||
|
||
def test2(self, _arg, ignored_barg): # no error here | ||
print(f"Argument value is {_arg}") | ||
|
||
def test3(self, dummy_param, arg2): # no error here | ||
print(f"arguments: {arg2}") |
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,9 @@ | ||
arguments-renamed:17:4:Orange.brew:Parameter 'fruit_name' has been renamed to 'orange_name' in overridden 'Orange.brew' method | ||
arguments-renamed:20:4:Orange.eat_with_condiment:Parameter 'fruit_name' has been renamed to 'orange_name' in overridden 'Orange.eat_with_condiment' method | ||
arguments-differ:27:4:Banana.eat_with_condiment:Number of parameters was 3 in 'Fruit.eat_with_condiment' and is now 4 in overridden 'Banana.eat_with_condiment' method | ||
arguments-renamed:40:4:Child.test:Parameter 'arg' has been renamed to 'arg1' in overridden 'Child.test' method | ||
arguments-renamed:43:4:Child.kwargs_test:Parameter 'var1' has been renamed to 'value1' in overridden 'Child.kwargs_test' method | ||
arguments-renamed:48:4:Child2.test:Parameter 'arg' has been renamed to 'var' in overridden 'Child2.test' method | ||
arguments-differ:51:4:Child2.kwargs_test:Number of parameters was 4 in 'Parent.kwargs_test' and is now 3 in overridden 'Child2.kwargs_test' method | ||
arguments-renamed:51:4:Child2.kwargs_test:Parameter 'var2' has been renamed to 'kw2' in overridden 'Child2.kwargs_test' method | ||
arguments-renamed:67:4:ChildDefaults.test1:Parameter 'barg' has been renamed to 'param2' in overridden 'ChildDefaults.test1' method |