Skip to content

Conversation

@mtshiba
Copy link
Contributor

@mtshiba mtshiba commented Oct 10, 2025

Summary

Based on @ibraheemdev's comment on #20792:

I think we can also update our bidirectional inference code, which makes the same assumption.

This PR also adds more test cases for how TypedDict annotations affect generic call inference.

Test Plan

New tests in typed_dict.md

@github-actions
Copy link
Contributor

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

reveal_type(homogeneous_list(1, 2, 3)) # revealed: list[Literal[1, 2, 3]]
plot2: Plot = {"y": homogeneous_list(1, 2, 3), "x": None}
reveal_type(plot2["y"]) # revealed: list[int]
# TODO: no error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be resolved by #20528.

@github-actions
Copy link
Contributor

mypy_primer results

Changes were detected when running on open source projects
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/_wheelfile.py:51:22: error[no-matching-overload] No overload of function `field` matches arguments
- Found 51 diagnostics
+ Found 52 diagnostics
No memory usage changes detected ✅

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Oct 10, 2025
@mtshiba mtshiba marked this pull request as ready for review October 10, 2025 18:18
@carljm carljm merged commit 11a9e7e into astral-sh:main Oct 10, 2025
42 checks passed
dcreager added a commit that referenced this pull request Oct 11, 2025
* main:
  [ty] bidirectional type inference using function return type annotations (#20528)
  [ty] use type context more aggressively to infer values ​​when constructing a `TypedDict` (#20806)
dcreager added a commit that referenced this pull request Oct 11, 2025
* dcreager/typevar-identity:
  [ty] bidirectional type inference using function return type annotations (#20528)
  [ty] use type context more aggressively to infer values ​​when constructing a `TypedDict` (#20806)
@mtshiba mtshiba mentioned this pull request Oct 14, 2025
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.

4 participants