-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Detect super()
call being used in the wrong context.
#2530
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2530 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 121 121
Lines 6477 6500 +23
Branches 1455 1462 +7
=========================================
+ Hits 6477 6500 +23
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@sobolevn I've implemented your suggestions, please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Some final remarks :)
] | ||
""" | ||
|
||
error_nested_methods = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still missing a correct test for this feature.
We need two:
- One with
super(klass, self)
(if it works in CPython) - With regular non-nested
super()
call - just to be sure
Reasoning: | ||
Call to `super()` without arguments will cause unexpected `TypeError` | ||
in a number of specific contexts, e.g. dict/set/list comprehensions | ||
and generator expressions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and nested functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not amend that, as e.g. here indicates perfectly well that the list is incomplete.
@sobolevn Added missing test case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Glad I could help. Till next year! P.S. Please do something about those |
What do you mean? |
For example, Yet right now they appear suddenly and force you to parse the output like this with your own eyes:
And don't get me started on the |
Yes, please! |
Resolves #2310.
I have made things!
I've decided not to include the case of
super()
in a nested function due to the nature of the error there being fundamentally different from what is described in the bug report.Checklist
CHANGELOG.md
Related issues
🙏 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.