[ty] Reject type[Callable] special form#23753
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.07%. The percentage of expected errors that received a diagnostic held steady at 77.62%. |
|
Memory usage reportMemory usage unchanged ✅ |
carljm
left a comment
There was a problem hiding this comment.
Thanks! Would be great to just clear out all these todo types with tighter validation instead (in separate PRs). It might reveal missing cases we should handle. If those are bigger features, they can remain more narrowly focused todo types.
| } | ||
| } | ||
| Type::SpecialForm(SpecialFormType::Callable) => { | ||
| invalid_type_argument(self, slice) |
There was a problem hiding this comment.
By not calling self.infer_type_expression(parameters) here (as the catch-all below does) we regress in missing out on some actionable nested diagnostics, e.g. in a case like type[Callable[..., Missing]] or a malformed Callable type expression inside type[].
|
|
@KotlinIsland Every type checker treats it as a special form, and typeshed defines it that way. Let's not debate that here. If you want to propose a spec change, go ahead, and we can discuss in the Discuss thread for that proposed change. |
1d6de92 to
c1ce778
Compare
Summary
The typing spec says:
We already reject
GenericandTypedDict. We should probably also rejectLiteral. But this PR addsCallable.Closes astral-sh/ty#2964.