Skip to content

Commit b2c12e8

Browse files
committed
Implement too-many-positional-arguments test for static and class methods
1 parent 55089d8 commit b2c12e8

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

tests/functional/t/too/too_many_positional_arguments.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=missing-function-docstring, missing-module-docstring
22
class RegularMethods:
3-
"""The max positional arguments default is 5. Regular methods doesn't count `self`."""
3+
"""The max positional arguments default is 5. Regular methods don't count `self`."""
44
# +1: [too-many-arguments, too-many-positional-arguments]
55
def regular_fail1(self, a, b, c, d, e, f):
66
pass
@@ -12,3 +12,43 @@ def regular_okay1(self, a, b, c, d, e, *, f=True):
1212
pass
1313
def regular_okay2(self, a, b, c, d, e):
1414
pass
15+
16+
17+
# pylint: disable=missing-function-docstring, missing-module-docstring
18+
class StaticMethods:
19+
"""The max positional arguments default is 5. Static methods count them all."""
20+
@staticmethod
21+
# +1: [too-many-arguments, too-many-positional-arguments]
22+
def static_fail1(a, b, c, d, e, f):
23+
pass
24+
@staticmethod
25+
# +1: [too-many-arguments, too-many-positional-arguments]
26+
def static_fail2(a, b, c, d, e, /, f):
27+
pass
28+
@staticmethod
29+
# +1: [too-many-arguments]
30+
def static_okay1(a, b, c, d, e, *, f=True):
31+
pass
32+
@staticmethod
33+
def static_okay2(a, b, c, d, e):
34+
pass
35+
36+
37+
# pylint: disable=missing-function-docstring, missing-module-docstring
38+
class ClassMethods:
39+
"""The max positional arguments default is 5. Class methods don't count `cls`."""
40+
@classmethod
41+
# +1: [too-many-arguments, too-many-positional-arguments]
42+
def class_fail1(cls, a, b, c, d, e, f):
43+
pass
44+
@classmethod
45+
# +1: [too-many-arguments, too-many-positional-arguments]
46+
def class_fail2(cls, a, b, c, d, e, /, f):
47+
pass
48+
@classmethod
49+
# +1: [too-many-arguments]
50+
def class_okay1(cls, a, b, c, d, e, *, f=True):
51+
pass
52+
@classmethod
53+
def class_okay2(cls, a, b, c, d, e):
54+
pass

tests/functional/t/too/too_many_positional_arguments.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@ too-many-positional-arguments:5:4:5:21:RegularMethods.regular_fail1:Too many pos
33
too-many-arguments:8:4:8:21:RegularMethods.regular_fail2:Too many arguments (7/6):UNDEFINED
44
too-many-positional-arguments:8:4:8:21:RegularMethods.regular_fail2:Too many positional arguments (7/6):HIGH
55
too-many-arguments:11:4:11:21:RegularMethods.regular_okay1:Too many arguments (7/6):UNDEFINED
6+
too-many-arguments:22:4:22:20:StaticMethods.static_fail1:Too many arguments (6/5):UNDEFINED
7+
too-many-positional-arguments:22:4:22:20:StaticMethods.static_fail1:Too many positional arguments (6/5):HIGH
8+
too-many-arguments:26:4:26:20:StaticMethods.static_fail2:Too many arguments (6/5):UNDEFINED
9+
too-many-positional-arguments:26:4:26:20:StaticMethods.static_fail2:Too many positional arguments (6/5):HIGH
10+
too-many-arguments:30:4:30:20:StaticMethods.static_okay1:Too many arguments (6/5):UNDEFINED
11+
too-many-arguments:42:4:42:19:ClassMethods.class_fail1:Too many arguments (7/6):UNDEFINED
12+
too-many-positional-arguments:42:4:42:19:ClassMethods.class_fail1:Too many positional arguments (7/6):HIGH
13+
too-many-arguments:46:4:46:19:ClassMethods.class_fail2:Too many arguments (7/6):UNDEFINED
14+
too-many-positional-arguments:46:4:46:19:ClassMethods.class_fail2:Too many positional arguments (7/6):HIGH
15+
too-many-arguments:50:4:50:19:ClassMethods.class_okay1:Too many arguments (7/6):UNDEFINED

0 commit comments

Comments
 (0)