Skip to content

[ty] Preserve recursive structure in Annotated values - #29058

Merged
charliermarsh merged 4 commits into
mainfrom
charlie/ty-3837-investigation
Oct 7, 2026
Merged

charliermarsh merged 4 commits into
mainfrom
charlie/ty-3837-investigation

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

We now terminate inference when an Annotated value recursively wraps its own inferred type:

from typing import Annotated, reveal_type
from ty_extensions._internal import TypeOf

value = int
while True:
    value = Annotated[TypeOf[value], "metadata"]
    reveal_type(value)

We preserve the Annotated wrapper when simplifying the recursive type, so inference can recognize the cycle and stop expanding it.

Addresses the runtime Annotated reproducer in astral-sh/ty#3837.

@charliermarsh charliermarsh added the ty The ty type checker label Oct 1, 2026
@astral-sh-bot

astral-sh-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 98.24%. The percentage of expected errors that received a diagnostic held steady at 98.24%. The number of fully passing files held steady at 134/146.

@astral-sh-bot

astral-sh-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@codspeed

codspeed Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 176 untouched benchmarks
⏩ 60 skipped benchmarks1


Comparing charlie/ty-3837-investigation (160e6dd) with main (030c500)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@charliermarsh
charliermarsh force-pushed the charlie/ty-3837-investigation branch from 3b91fb0 to 13f1ee1 Compare October 1, 2026 23:45
@charliermarsh
charliermarsh marked this pull request as ready for review October 1, 2026 23:52
@charliermarsh
charliermarsh requested a review from a team as a code owner October 1, 2026 23:52
@astral-sh-bot
astral-sh-bot Bot requested a review from dhruvmanila October 1, 2026 23:52
@charliermarsh charliermarsh added the bug An issue describing something that isn't working, or a PR that fixes a bug label Oct 1, 2026
@charliermarsh
charliermarsh force-pushed the charlie/ty-3837-investigation branch from 13f1ee1 to 1393070 Compare October 2, 2026 20:05
@charliermarsh
charliermarsh force-pushed the charlie/ty-3837-investigation branch from 1393070 to f46fb5b Compare October 5, 2026 14:42
@charliermarsh
charliermarsh force-pushed the charlie/ty-3837-investigation branch from f46fb5b to df83095 Compare October 7, 2026 02:00
Comment thread crates/ty_python_semantic/src/types/relation.rs
@charliermarsh
charliermarsh merged commit 02f3326 into main Oct 7, 2026
75 checks passed
@charliermarsh
charliermarsh deleted the charlie/ty-3837-investigation branch October 7, 2026 13:23

This branch was successfully deployed

1 active deployment
automations — 160e6dd0 Deployed Oct 7, 2026 by charliermarsh via security-review / security review #90954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants