Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Preserve transparent callable decorators#25030

Merged
dhruvmanila merged 6 commits into
mainfrom
dhruv/transparent-callable-decorator
Jun 6, 2026
Merged

[ty] Preserve transparent callable decorators#25030
dhruvmanila merged 6 commits into
mainfrom
dhruv/transparent-callable-decorator

Conversation

@dhruvmanila

@dhruvmanila dhruvmanila commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

temporary workaround for astral-sh/ty#2278

This is a temporary fix to special case the (arg: Callable[P, R]) -> Callable[P, R] callable which takes in a single parameter annotated as a Callable[P, R] and returns the same callable with the same type variables.

This special case is ofcourse very limited because it only looks for specific Callable[P, R] type (and a type alias that corresponds to that callable) and nothing else.

Test Plan

Add a couple of test cases both for overloaded and non-overloaded function.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label May 7, 2026
@astral-sh-bot

astral-sh-bot Bot commented May 7, 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 92.16%. The percentage of expected errors that received a diagnostic held steady at 87.31%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented May 7, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented May 7, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@dhruvmanila dhruvmanila force-pushed the dhruv/transparent-callable-decorator branch from c36d7f9 to 1ca588f Compare May 8, 2026 16:25
@dhruvmanila dhruvmanila marked this pull request as ready for review May 8, 2026 16:37
@dhruvmanila dhruvmanila marked this pull request as draft May 28, 2026 05:01
@dhruvmanila

This comment was marked as outdated.

@dhruvmanila dhruvmanila force-pushed the dhruv/transparent-callable-decorator branch from b6e2fcc to 97616f7 Compare June 5, 2026 15:40
@dhruvmanila dhruvmanila marked this pull request as ready for review June 5, 2026 15: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.

Looks good, thank you! Comments could also be follow-ups.

Comment thread crates/ty_python_semantic/src/types/infer/builder.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder.rs Outdated
@dhruvmanila dhruvmanila assigned carljm and unassigned dcreager Jun 6, 2026
@dhruvmanila dhruvmanila enabled auto-merge (squash) June 6, 2026 09:08
@dhruvmanila dhruvmanila merged commit f414174 into main Jun 6, 2026
57 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/transparent-callable-decorator branch June 6, 2026 09:11
charliermarsh pushed a commit that referenced this pull request Jun 10, 2026
## Summary

The workaround from #25030 only inspected function literals and direct
`Callable` types. Polars types both decorators on `LazyFrame.collect` as
an `IdentityFunction` protocol, so ty represented the decorator
expressions as protocol instances and discarded the overload signatures.

This follow-up resolves the protocol's bound `__call__` method through
the existing callable upcast path, while retaining the strict
`Callable[P, R] -> Callable[P, R]` signature check.

Fixes the remaining Polars example reported in astral-sh/ty#2278.

## Test plan

Add a regression test case for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants