Repository navigation
fix: preserve definition locals for postponed task annotations - #1026
Merged
Merged
Conversation
tobiasraabe
added this pull request to stack #1027
October 14, 2026 04:27
tobiasraabe
force-pushed
the
codex/postponed-annotation-snapshots
branch
from
October 17, 2026 08:56
f895e84 to
858157f
Compare
tobiasraabe
force-pushed
the
codex/postponed-annotation-snapshots
branch
from
October 17, 2026 09:18
1a3d716 to
94c335c
Compare
tobiasraabe
marked this pull request as ready for review
October 17, 2026 09:18
tobiasraabe
force-pushed
the
codex/postponed-annotation-snapshots
branch
from
October 17, 2026 09:30
94c335c to
c799064
Compare
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.
Nested tasks defined with
from __future__ import annotationslost the enclosing function's local bindings before collection. Generated tasks whose product path existed only in an annotation therefore failed withNameErroror could resolve against the final loop value.Capture a separate shallow definition-local snapshot for each decorated task, including future annotations. Referenced objects remain shared; module-level future annotations continue to use current globals, and native module-level loop behavior is preserved. Release snapshots after collection and its modification hooks finish, including generated-child collection, collection-hook failures, and children registered before a generator body raises. Internal registration through the programmatic interface and
after=does not retain pytask's own locals as the task's annotation namespace.Regression tests cover per-task outputs, shallow sharing, plugin access during collection, programmatic registration, snapshot release, and pickling. Generator-body failure tests verify cleanup after
RuntimeErrorandSystemExit, preservation of the original exception, and pickling of retained children with an unrelated generator-local lock. Sixafter=cases exercise global names colliding with internal locals under native and future annotations. The generator notebook asserts copied contents, and workflow filters accept slash-containing base branches.Validation:
after=cases failed on Python 3.14 before the fix.just lintandjust typingpassed.Follow-up work: annotation resolution when task callables are reused or later hooks revisit previously collected tasks. Broader transactional expansion and continued execution remain separate work under #985.
Follows #1025, which is now merged into
main.