Skip to content

Fix flaky recursion in recursive forward-reference resolution#4754

Merged
Zac-HD merged 1 commit into
HypothesisWorks:masterfrom
Zac-HD:claude/nice-goodall-HrUmp
May 28, 2026
Merged

Fix flaky recursion in recursive forward-reference resolution#4754
Zac-HD merged 1 commit into
HypothesisWorks:masterfrom
Zac-HD:claude/nice-goodall-HrUmp

Conversation

@Zac-HD
Copy link
Copy Markdown
Member

@Zac-HD Zac-HD commented May 27, 2026

Resolving recursive forward references such as A = list[Union["A", str]] recursed once per available stack frame until hitting a RecursionError, then fell back to a deferred strategy. Termination therefore depended on the ambient stack depth, which made resolution flaky (spurious RecursionError and other intermittent failures). Break the cycle eagerly by deferring when we re-enter resolution of a type whose forward reference we are already resolving, so resolution uses a small and constant amount of stack.

Comment thread hypothesis/tests/nocover/test_type_lookup_forward_ref.py Outdated
@Zac-HD Zac-HD force-pushed the claude/nice-goodall-HrUmp branch from c202e5d to 66cf41c Compare May 28, 2026 06:16
Resolving recursive forward references such as A = list[Union["A", str]]
recursed once per available stack frame until hitting a RecursionError, then
fell back to a deferred strategy. Termination therefore depended on the ambient
stack depth, which made resolution flaky (spurious RecursionError and other
intermittent failures). Break the cycle eagerly by deferring when we re-enter
resolution of a type whose forward reference we are already resolving, so
resolution uses a small and constant amount of stack.

https://claude.ai/code/session_01F7S7ua4joqKCzxbMxQWj5R
@Zac-HD Zac-HD force-pushed the claude/nice-goodall-HrUmp branch from 66cf41c to f3cbde1 Compare May 28, 2026 06:23
@Zac-HD Zac-HD enabled auto-merge May 28, 2026 06:42
@Zac-HD Zac-HD merged commit b46b502 into HypothesisWorks:master May 28, 2026
148 of 153 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants