Skip to content

[ty] Keep unresolved TypeIs targets provisional - #29066

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/ty-3837-typeis
Oct 3, 2026
Merged

charliermarsh merged 1 commit into
mainfrom
charlie/ty-3837-typeis

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

We now terminate inference for recursive TypeIs calls like this one:

from typing import reveal_type
from typing_extensions import TypeIs

class Container[T]: ...

def is_container[T](value: object, other: T) -> TypeIs[Container[T]]:
    return True

while True:
    if is_container(value, type(value)):
        value = value.__str__
    else:
        value = {value}
    reveal_type(value)

Previously, an unresolved TypeIs target could make the else branch appear unreachable. We now defer that narrowing until the target is known, preserving the recursive type and diagnostics in both branches.

Addresses astral-sh/ty#3837.

@charliermarsh charliermarsh added the ty The ty type checker label Oct 1, 2026
@charliermarsh
charliermarsh force-pushed the charlie/ty-3837-typeis branch from 5e85919 to 14f2ad2 Compare October 1, 2026 23:45
@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 ✅

Full report with detailed diff (timing results)

@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
@charliermarsh charliermarsh added the bug An issue describing something that isn't working, or a PR that fixes a bug label Oct 1, 2026
@astral-sh-bot
astral-sh-bot Bot requested a review from carljm October 1, 2026 23:52

@carljm carljm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@charliermarsh
charliermarsh merged commit 127e77e into main Oct 3, 2026
76 checks passed
@charliermarsh
charliermarsh deleted the charlie/ty-3837-typeis branch October 3, 2026 00:12

This branch was previously deployed

1 inactive deployment
automations — ad4edc4d Deployed Oct 2, 2026 by charliermarsh via security-review / security review #90615
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