-
Notifications
You must be signed in to change notification settings - Fork 134
Description
Currently, the general callable type uses a manual implementation to check whether the two types are equivalent (is_equivalent_to). This is required for two reasons:
- The type of the default values don't participate in checking for equivalence, it's only the optionality that participates i.e., is the parameter required for both callable types or not?
- The name of positional-only, variadic and keyword-variadic parameters don't participate in checking for equivalence
Refer to astral-sh/ruff#16698 (comment) for previous discussion.
A possible option that's discussed in the above thread is to erase the information that doesn't participate in equivalence relation (above two points) when constructing a GeneralCallableType from a function literal. This will mean that we can remove the manual implementation and it will then use the catch-all branch:
This has the benefit that the equivalence is maintained at the type level. But, this does mean that (a) we'll need to make name: Name into name: Option<Name> to erase it or replace it with Name("") (empty name seems error prone) and (b) use something else for the default type as Type::Unknown is not a static type, maybe just replace it with None.