[ty] Add support for typing.Concatenate by dhruvmanila · Pull Request #23689 · astral-sh/ruff (original) (raw)
added the ty
Multi-file analysis & type inference
label
dhruvmanila changed the base branch from main to dhruv/paramspec-relation-check
Base automatically changed from dhruv/paramspec-relation-check to main
dhruvmanila added a commit that referenced this pull request
Summary
This PR updates the constraint set assignability check to only special
case overloaded callables against a callable containing ParamSpec and
pass through any other callables to the check in Signature. This is to
make sure for Concatenate (ref #23689) that we make sure that it goes
through to Signature where the type checking / constraint set building
would take place.
Here are the detailed list of changes:
In check_callable_signature_pair_inner,
- Delegate the branch where both sides contain single signature with
ParamSpecas the only parameter tocheck_signature_pair - For other branches where one side contain a single signature with
ParamSpecas the only parameter, update the other side to check whether it's an overloaded callable. The reason is that thesignatures_is_single_paramspeccan returnNoneeven for non-overloaded non-ParamSpec callable which we should delegate tocheck_signature_pair
In check_signature_pair_inner,
- Move the constraint set assignability branch before any special case
of
Topand gradual form handling. This is to support the delegation that happened fromcheck_callable_signature_pair_innerso that the constraint set contains a node for theParamSpectype variable because otherwise we would've short-circuit forTop/ gradual form cases.
Test Plan
Make sure there are no regression and existing test cases pass.
I'm also working on top of this branch in #23689 to make sure these changes are valid, so far so good.
Co-authored-by: Valentin Iovene val@physight.com
carljm removed their request for review
carljm added a commit that referenced this pull request
- main:
[ty] make
test-casea dev-dependency (#24187) [ty] implement cycle normalization for more types to prevent too-many-cycle panics (#24061) [ty] Silence all diagnostics in unreachable code (#24179) [ty] InternInferableTypeVars(#24161) Implement unnecessary-if (RUF050) (#24114) RecognizeSelfannotation andselfassignment in SLF001 (#24144) Bump the npm version before publish (#24178) [ty] Disallow Self in metaclass and static methods (#23231) Use trusted publishing for NPM packages (#24171) [ty] Respect non-explicitly defined dataclass params (#24170) Add RUF072: warn when using operator on an f-string (#24162) [ty] Check return type of generator functions (#24026) Implement useless-finally (RUF-072) (#24165) [ty] Add test for a dataclass with a default field converter (#24169) [ty] Dataclass field converters (#23088) [flake8-bandit] Treat sys.executable as trusted input in S603 (#24106) [ty] Add support fortyping.Concatenate(#23689)ASYNC115: autofix to use full qualifiedanyio.lowlevelimport (#24166) [ty] Disallow read-only fields in TypedDict updates (#24128) Speed up diagnostic rendering (#24146)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})