Reference implementation for PEP 828#145716
Draft
ZeroIntensity wants to merge 56 commits intopython:mainfrom
Draft
Reference implementation for PEP 828#145716ZeroIntensity wants to merge 56 commits intopython:mainfrom
ZeroIntensity wants to merge 56 commits intopython:mainfrom
Conversation
Fix `yield from` not working on non-iterator iterables inside async generators
ZeroIntensity
commented
Mar 26, 2026
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Documentation build overview
40 files changed ·
|
Implement `visit_AsyncYieldFrom` in Python unparse
Rename every test in `TestPEP828Operation` and `TestInterestingEdgeCases` to its `test_yield_from` sibling's name with an `_ayf` suffix, so the two suites map onto each other mechanically. Add `TestParityWithPEP380`, which uses `assert_parity` to enforce that each mirrored class is in symmetric parity: every PEP 380 test has a corresponding `_ayf` variant, and every variant has a PEP 380 base. A missing variant or an unmatched extra both fail the parity test. Move `test_delegate_exception` (the only PEP 828-only test) into a new `TestPEP828Extras` class. Tests that have no PEP 380 analogue belong there; the parity classes stay strictly mirrored. Lazy-import `test_yield_from` so the parity machinery doesn't pull it in unless the parity tests actually run.
Note the `_ayf` naming convention, the 1:1 parity check enforced by `TestParityWithPEP380`, and where PEP 828-only tests belong.
Mirrored test method names already match their PEP 380 counterparts via the `_ayf` suffix. The descriptions and subTest labels now use the async API names (`asend`, `aclose`, `athrow`, `anext`) so it is clear which operation each test exercises. Class docstrings on `TestPEP828Operation` and `TestInterestingEdgeCases` now state that they mirror their `test_yield_from` counterparts.
The previous wording instructed maintainers to keep the two suites in sync manually; that contract is now enforced by `TestParityWithPEP380` on the async side, so the cross-reference can stay minimal.
The `yielded_first` / `yielded_second` / `returned` placeholders were created with `object()`, which renders as a generic repr in failure output. Switching to `sentinel(...)` keeps the same identity semantics while giving each marker a meaningful repr.
Print each offender on its own line, labelled with which side is missing
the counterpart, instead of dumping two summary sentences with embedded
list reprs. Factor the duplicated set-comprehension into a small inner
helper so the assertion body is also a touch shorter.
Sample failure (deleting one mirrored test, adding two extras):
TestPEP828Operation is not a 1:1 mirror of TestPEP380Operation (suffix '_ayf'):
missing in TestPEP828Operation: test_yield_from_empty_ayf
no counterpart in TestPEP380Operation: test_made_up_extra_ayf
no counterpart in TestPEP380Operation: test_other_extra_ayf
When the mirrored classes share an unqualified name (e.g. both PEP 380 and PEP 828 have a `TestInterestingEdgeCases`), the failure message talked about the class on both sides as if it were the same class. Use `module.qualname` so each side is unambiguous.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not a real PR; this will be linked in the PEP so people can comment on the diff.