-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Extra arg for "method" (self) and "classmethod" (cls) (continued) #10885
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
133c31b
Extra arg for "method" (self) and "classmethod" (cls)
fgallaire 6a53e61
Fix max_positional_arguments, fix tests
fgallaire 2b9963d
Add a new fragment (#8675)
fgallaire d35ffcf
Fix (false positive) E0606
fgallaire 68d8288
Remove too-many-arguments disables no longer needed
RomanValov 01c19a3
Prepare too-many-positional-arguments test for static and class methods
fgallaire fdab22d
Implement too-many-positional-arguments test for static and class metβ¦
RomanValov 2121a9a
Don't count first argument rather then increase args limits
RomanValov 2b4bd41
Fix condition
RomanValov f8012a0
Align behavior of error message counters to not count ignored args
RomanValov a40c536
Add tests for interference between first argument and ignored arguments
RomanValov ce76c9d
Add backticks
jacobtylerwalls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| Fix a false positive for ``too-many-arguments`` in (non-static) methods and classmethods. | ||
|
|
||
| Closes #8675 |
This file contains hidden or 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 hidden or 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 hidden or 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
143 changes: 138 additions & 5 deletions
143
tests/functional/t/too/too_many_positional_arguments.py
This file contains hidden or 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,9 +1,142 @@ | ||
| # pylint: disable=missing-function-docstring, missing-module-docstring | ||
| class FiveArgumentMethods: | ||
| """The max positional arguments default is 5.""" | ||
| def fail1(self, a, b, c, d, e): # [too-many-arguments, too-many-positional-arguments] | ||
| class RegularMethods: | ||
| """The max positional arguments default is 5. Regular methods don't count `self`.""" | ||
|
|
||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def regular_fail1(self, a, b, c, d, e, f): | ||
| pass | ||
| def fail2(self, a, b, c, d, /, e): # [too-many-arguments, too-many-positional-arguments] | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def regular_fail2(self, a, b, c, d, e, /, f): | ||
| pass | ||
| def okay1(self, a, b, c, d, *, e=True): # [too-many-arguments] | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def regular_fail3(self, /, a, b, c, d, e, f): | ||
| pass | ||
| # +1: [too-many-arguments] | ||
| def regular_soso1(self, a, b, c, d, e, *, f=True): | ||
| pass | ||
| # +1: [too-many-arguments] | ||
| def regular_soso2(self, a, b, c, d, e, /, *, f=True): | ||
| pass | ||
| # +1: [too-many-arguments] | ||
| def regular_soso3(self, /, a, b, c, d, e, *, f=True): | ||
| pass | ||
| # +1: [too-many-arguments] | ||
| def regular_soso4(self, a, b, c, d, e, /, _f, *, g=True): | ||
| pass | ||
| # +1: [too-many-arguments] | ||
| def regular_soso5(self, /, _a, b, c, d, e, f, *, g=True): | ||
| pass | ||
| def regular_okay1(self, a, b, c, d, e): | ||
| pass | ||
| def regular_okay2(self, a, b, c, d, e, /): | ||
| pass | ||
| def regular_okay3(self, *, a, b, c, d, e): | ||
| pass | ||
| def regular_okay4(self, a, b, c, d, e, /, _f): | ||
| pass | ||
| def regular_okay5(self, _a, b, c, d, e, /, f): | ||
| pass | ||
| def regular_okay6(self, /, _a, b, c, d, e, f): | ||
| pass | ||
| def regular_okay7(self, /, a, b, c, d, e, _f): | ||
| pass | ||
|
|
||
|
|
||
| # pylint: disable=missing-function-docstring, missing-module-docstring | ||
| class StaticMethods: | ||
| """The max positional arguments default is 5. Static methods count them all.""" | ||
|
|
||
| @staticmethod | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def static_fail1(a, b, c, d, e, f): | ||
| pass | ||
| @staticmethod | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def static_fail2(a, b, c, d, e, /, f): | ||
| pass | ||
| @staticmethod | ||
| # +1: [too-many-arguments] | ||
| def static_soso1(a, b, c, d, e, *, f=True): | ||
| pass | ||
| @staticmethod | ||
| # +1: [too-many-arguments] | ||
| def static_soso2(a, b, c, d, e, /, *, f=True): | ||
| pass | ||
| @staticmethod | ||
| # +1: [too-many-arguments] | ||
| def static_soso3(a, b, c, d, e, /, _f, *, g=True): | ||
| pass | ||
| @staticmethod | ||
| def static_okay1(a, b, c, d, e): | ||
| pass | ||
| @staticmethod | ||
| def static_okay2(a, b, c, d, e, /): | ||
| pass | ||
| @staticmethod | ||
| def static_okay3(*, a, b, c, d, e): | ||
| pass | ||
| @staticmethod | ||
| def static_okay4(a, b, c, d, e, /, _f): | ||
| pass | ||
| @staticmethod | ||
| def static_okay5(_a, b, c, d, e, /, f): | ||
| pass | ||
|
|
||
|
|
||
| # pylint: disable=missing-function-docstring, missing-module-docstring | ||
| class ClassMethods: | ||
| """The max positional arguments default is 5. Class methods don't count `cls`.""" | ||
|
|
||
| @classmethod | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def class_fail1(cls, a, b, c, d, e, f): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def class_fail2(cls, a, b, c, d, e, /, f): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments, too-many-positional-arguments] | ||
| def class_fail3(cls, /, a, b, c, d, e, f): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments] | ||
| def class_soso1(cls, a, b, c, d, e, *, f=True): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments] | ||
| def class_soso2(cls, a, b, c, d, e, /, *, f=True): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments] | ||
| def class_soso3(cls, /, a, b, c, d, e, *, f=True): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments] | ||
| def class_soso4(cls, a, b, c, d, e, /, _f, *, g=True): | ||
| pass | ||
| @classmethod | ||
| # +1: [too-many-arguments] | ||
| def class_soso5(cls, /, _a, b, c, d, e, f, *, g=True): | ||
| pass | ||
| @classmethod | ||
| def class_okay1(cls, a, b, c, d, e): | ||
| pass | ||
| @classmethod | ||
| def class_okay2(cls, a, b, c, d, e, /): | ||
| pass | ||
| @classmethod | ||
| def class_okay3(cls, *, a, b, c, d, e): | ||
| pass | ||
| @classmethod | ||
| def class_okay4(cls, a, b, c, d, e, /, _f): | ||
| pass | ||
| @classmethod | ||
| def class_okay5(cls, _a, b, c, d, e, /, f): | ||
| pass | ||
| @classmethod | ||
| def class_okay6(cls, /, _a, b, c, d, e, f): | ||
| pass | ||
| @classmethod | ||
| def class_okay7(cls, /, a, b, c, d, e, _f): | ||
| pass |
This file contains hidden or 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,5 +1,29 @@ | ||
| too-many-arguments:4:4:4:13:FiveArgumentMethods.fail1:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:4:4:4:13:FiveArgumentMethods.fail1:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:6:4:6:13:FiveArgumentMethods.fail2:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:6:4:6:13:FiveArgumentMethods.fail2:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:8:4:8:13:FiveArgumentMethods.okay1:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:6:4:6:21:RegularMethods.regular_fail1:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:6:4:6:21:RegularMethods.regular_fail1:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:9:4:9:21:RegularMethods.regular_fail2:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:9:4:9:21:RegularMethods.regular_fail2:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:12:4:12:21:RegularMethods.regular_fail3:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:12:4:12:21:RegularMethods.regular_fail3:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:15:4:15:21:RegularMethods.regular_soso1:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:18:4:18:21:RegularMethods.regular_soso2:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:21:4:21:21:RegularMethods.regular_soso3:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:24:4:24:21:RegularMethods.regular_soso4:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:27:4:27:21:RegularMethods.regular_soso5:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:51:4:51:20:StaticMethods.static_fail1:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:51:4:51:20:StaticMethods.static_fail1:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:55:4:55:20:StaticMethods.static_fail2:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:55:4:55:20:StaticMethods.static_fail2:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:59:4:59:20:StaticMethods.static_soso1:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:63:4:63:20:StaticMethods.static_soso2:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:67:4:67:20:StaticMethods.static_soso3:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:92:4:92:19:ClassMethods.class_fail1:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:92:4:92:19:ClassMethods.class_fail1:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:96:4:96:19:ClassMethods.class_fail2:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:96:4:96:19:ClassMethods.class_fail2:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:100:4:100:19:ClassMethods.class_fail3:Too many arguments (6/5):UNDEFINED | ||
| too-many-positional-arguments:100:4:100:19:ClassMethods.class_fail3:Too many positional arguments (6/5):HIGH | ||
| too-many-arguments:104:4:104:19:ClassMethods.class_soso1:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:108:4:108:19:ClassMethods.class_soso2:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:112:4:112:19:ClassMethods.class_soso3:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:116:4:116:19:ClassMethods.class_soso4:Too many arguments (6/5):UNDEFINED | ||
| too-many-arguments:120:4:120:19:ClassMethods.class_soso5:Too many arguments (6/5):UNDEFINED |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.