Skip to content

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
@codecov
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 612 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%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
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/4.0.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
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 <jake.lishman@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported 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