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

Fix false positive in use-yield-from when using yield return #9700

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

jakelishman
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

If the return value from yield is inspected inline, such as by (augmented) assignment, changing the looped yield to yield from is very likely to change the semantics of the generator, since there is an implicit use of generator.send.

The type-hint component of #9696 feels (to me) like it would be suitable to suppress with a local lint suppression rather than complex type inference within pylint; it's a pretty unusual construction.

Closes #9696

If the return value from `yield` is inspected inline, such as by
(augmented) assignment, changing the looped `yield` to `yield from` is
very likely to change the semantics of the generator, since there is an
implicit use of `generator.send`.

Closes pylint-dev#9696
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.84%. Comparing base (1c496e9) to head (7222319).
Report is 140 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9700   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files         174      174           
  Lines       18862    18862           
=======================================
  Hits        18078    18078           
  Misses        784      784           
Files with missing lines Coverage Ξ”
pylint/checkers/refactoring/refactoring_checker.py 98.27% <100.00%> (ΓΈ)

Copy link
Contributor

github-actions bot commented Jun 6, 2024

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 7222319

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/3.3.x labels Jun 6, 2024
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.2.3 milestone Jun 6, 2024
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you ! We're going to release this in the next patch release (3.2.3).

@Pierre-Sassoulas Pierre-Sassoulas merged commit ea73bae into pylint-dev:main Jun 6, 2024
48 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 6, 2024
If the return value from `yield` is inspected inline, such as by
(augmented) assignment, changing the looped `yield` to `yield from` is
very likely to change the semantics of the generator, since there is an
implicit use of `generator.send`.

Closes #9696

(cherry picked from commit ea73bae)
@jakelishman jakelishman deleted the yield-from branch June 6, 2024 13:03
Pierre-Sassoulas pushed a commit that referenced this pull request Jun 6, 2024
…) (#9701)

If the return value from `yield` is inspected inline, such as by
(augmented) assignment, changing the looped `yield` to `yield from` is
very likely to change the semantics of the generator, since there is an
implicit use of `generator.send`.

Closes #9696

(cherry picked from commit ea73bae)

Co-authored-by: Jake Lishman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport maintenance/3.3.x False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive for use-yield-from for generators yielding from iterators
2 participants