[ty] Further improve details around which expressions should be deferred in stub files#21456
[ty] Further improve details around which expressions should be deferred in stub files#21456AlexWaygood merged 2 commits intomainfrom
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
deferred_state after parsing a type expression|
Lots of new sympy diagnostics, but I think that's just because we now understand some type aliases that were previously inferred as |
not sure what's going on here but it looks like a pre-existing issue. I get lots of these diagnostics if I run |
Yes, it's because we now understand this typeshed type alias, which is used as the upper bound for this typeshed TypeVar, which is used in this typeshed method annotation |
carljm
left a comment
There was a problem hiding this comment.
Might have been simpler to defer the PEP 613 part of this to the PEP 613 PR, but the conflict should be minor. Thank you!
Yeah — I initially did it without that bit but it led to a few ecosystem regressions without the r.h.s. of PEP-613 aliases being deferred! |
* origin/main: (59 commits) [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461) [ty] Improve literal promotion heuristics (#21439) [ty] Further improve details around which expressions should be deferred in stub files (#21456) [ty] Improve generic class constructor inference (#21442) [ty] Propagate type context through conditional expressions (#21443) [ty] Suppress completions when introducing names with `as` [ty] Add panic-by-default await methods to `TestServer` (#21451) [ty] name is parameter and global is a syntax error (#21312) [ty] Fixup a few details around version-specific dataclass features (#21453) [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449) [ty] Support stringified annotations in value-position `Annotated` instances (#21447) [ty] Type inference for genererator expressions (#21437) [ty] Make `__getattr__` available for `ModuleType` instances (#21450) [ty] Increase default receive timeout in tests to 10s (#21448) [ty] Add synthetic members to completions on dataclasses (#21446) [ty] Support legacy `typing` special forms in implicit type aliases (#21433) Bump 0.14.5 (#21435) [ty] Support `type[…]` and `Type[…]` in implicit type aliases (#21421) [ty] Respect notebook cell boundaries when adding an auto import (#21322) Update PyCharm setup instructions (#21409) ...
* dcreager/deep-comparison: (64 commits) assuming SubtypingAssuming implies_subtype_of name tweak Apply suggestions from code review [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461) [ty] Improve literal promotion heuristics (#21439) [ty] Further improve details around which expressions should be deferred in stub files (#21456) [ty] Improve generic class constructor inference (#21442) [ty] Propagate type context through conditional expressions (#21443) [ty] Suppress completions when introducing names with `as` [ty] Add panic-by-default await methods to `TestServer` (#21451) [ty] name is parameter and global is a syntax error (#21312) [ty] Fixup a few details around version-specific dataclass features (#21453) [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449) [ty] Support stringified annotations in value-position `Annotated` instances (#21447) [ty] Type inference for genererator expressions (#21437) [ty] Make `__getattr__` available for `ModuleType` instances (#21450) [ty] Increase default receive timeout in tests to 10s (#21448) [ty] Add synthetic members to completions on dataclasses (#21446) ...
Summary
deferred_stateafter parsing a type expression: we don't want that state leaking out into other contexts where we shouldn't be deferring expression inferenceT: TypeAlias = X | Yin a stub fileAddresses @carljm's review in #21401 (comment)
Test Plan
I added a regression test for a regression that the first version of this PR introduced (we need to make sure the r.h.s. of a PEP-613
TypeAliases is always deferred in a stub file)