[ty] Emit "arguments after ** must be a mapping" before overload resolution#22921
Conversation
54c1d56 to
1f91ae1
Compare
Typing conformance resultsNo changes detected ✅ |
|
| for keyword in arguments.keywords.iter().filter(|k| k.arg.is_none()) { | ||
| let mapping_type = self.expression_type(&keyword.value); | ||
|
|
||
| let is_paramspec = matches!( |
There was a problem hiding this comment.
Does it make sense to skip the mapping check for ParamSpec and Union[ParamSpec, Unknown] types here?
The test under pep695/paramspec.md would fail otherwise also
Flagging it here would be a premature false positive
There was a problem hiding this comment.
Yeah, we'd need to skip those in here. It's a bit unfortunate that this would lead to duplicate code. If you can find a way to de-duplicate it, that would be great. I think one way would be to have a as_paramspec_typevar method which returns Option<Type> if it's P or P | Unknown.
There was a problem hiding this comment.
Updated to use common method across all cases where this duplicated logic was used
|
The failing CI is from pre-current version of the commit I believe |
|
This new check now points to the actual value (expression after **) not the whole **expr which seems more precise to be and okay? For some cases like cloud-init it's now invalid-argument-type and not no-matching-overload |
Yeah, this seems good to me. |
** must be a mapping" before overload resolution
dhruvmanila
left a comment
There was a problem hiding this comment.
ty for following through with this additional PR :)
Summary
Closes astral-sh/ty#2653
Move the KeywordsNotAMapping check from bind.rs to builder.rs, matching the existing pattern for starred argument iterability. This ensures users see "must be a mapping type" instead of "no matching overload" when passing a non-mapping **kwargs to an overloaded function.
Test Plan
Added test case for **kwargs with non-mapping types on overloaded functions in function.md.