ignore one arg when checking class method arg length#3139
ignore one arg when checking class method arg length#3139sobolevn merged 2 commits intowemake-services:masterfrom
Conversation
b3cab88 to
79c2cf3
Compare
79c2cf3 to
bd23f18
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3139 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 117 118 +1
Lines 6083 5919 -164
Branches 901 856 -45
==========================================
- Hits 6083 5919 -164 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| """Checks the number of the arguments in a function.""" | ||
| self.check_arguments_count_any(node) | ||
| parent = get_parent(node) | ||
| if isinstance(parent, ast.ClassDef) and not self._check_staticmethod( |
There was a problem hiding this comment.
Maybe instead we should just ignore first arg named self / cls / mc? We even have _get_args_without_special_argument for that.
There was a problem hiding this comment.
Are you suggesting switching
wemake_python_styleguide.logic.tree.functions.get_all_arguments
to
wemake_python_styleguide.logic.arguments.function_args._get_args_without_special_argument
around line 51?
Of course I would make the function public and update callers, etc etc. I just want to confirm I understand this right.
There was a problem hiding this comment.
Yes, this seems like the simpliest solution.
There was a problem hiding this comment.
I took a look and that doesn't seem to work. The function doesn't grab keyword or variable length arguments. I did refactor a little bit to try and reuse some of that code though.
sobolevn
left a comment
There was a problem hiding this comment.
Looks great now! Please, add a changelog entry.
sobolevn
left a comment
There was a problem hiding this comment.
Nevermind, I will do that :)
Thanks!
fixes #2394
I have made things!
I'll be happy to update the documentation to say the WPS211 uses an arg - 1 for validating class methods, but I'm not sure exactly where.
I also don't know what to put in the changelog.
Checklist
CHANGELOG.mdRelated issues
Closes #2394
🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.