Skip to content
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

[return-arg-in-generator] Add a details.rst only as the message is not raised anymore #8191

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/data/messages/r/return-arg-in-generator/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This is a message that isn't going to be raised for python > 3.3. It was raised
for code like::

def interrogate_until_you_find_jack(pirates):
for pirate in pirates:
if pirate == "Captain Jack Sparrow":
return "Arrr! We've found our captain!"
yield pirate

Which is now valid and equivalent to the previously expected::

def interrogate_until_you_find_jack(pirates):
for pirate in pirates:
if pirate == "Captain Jack Sparrow":
raise StopIteration("Arrr! We've found our captain!")
yield pirate
2 changes: 2 additions & 0 deletions doc/data/messages/r/return-arg-in-generator/related.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `PEP380 <https://peps.python.org/pep-0380/>`_
- `Stackoverflow explanation <https://stackoverflow.com/a/16780113/2519059>`_
6 changes: 3 additions & 3 deletions doc/user_guide/checkers/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ Basic checker Messages
:return-outside-function (E0104): *Return outside function*
Used when a "return" statement is found outside a function or method.
:return-arg-in-generator (E0106): *Return with argument inside generator*
Used when a "return" statement with an argument is found outside in a
generator function or method (e.g. with some "yield" statements). This
message can't be emitted when using Python >= 3.3.
Used when a "return" statement with an argument is found in a generator
function or method (e.g. with some "yield" statements). This message can't be
emitted when using Python >= 3.3.
:invalid-star-assignment-target (E0113): *Starred assignment target must be in a list or tuple*
Emitted when a star expression is used as a starred assignment target.
:bad-reversed-sequence (E0111): *The first reversed() argument is not a sequence*
Expand Down
3 changes: 1 addition & 2 deletions pylint/checkers/base/basic_error_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class BasicErrorChecker(_BasicChecker):
"Return with argument inside generator",
"return-arg-in-generator",
'Used when a "return" statement with an argument is found '
"outside in a generator function or method (e.g. with some "
'"yield" statements).',
'in a generator function or method (e.g. with some "yield" statements).',
{"maxversion": (3, 3)},
),
"E0107": (
Expand Down