mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:23:11 +00:00
![]() ## Summary Currently our `Type::Callable` wraps a four-variant `CallableType` enum. But as time has gone on, I think we've found that the four variants in `CallableType` are really more different to each other than they are similar to each other: - `GeneralCallableType` is a structural type describing all callable types with a certain signature, but the other three types are "literal types", more similar to the `FunctionLiteral` variant - `GeneralCallableType` is not a singleton or a single-valued type, but the other three are all single-valued types (`WrapperDescriptorDunderGet` is even a singleton type) - `GeneralCallableType` has (or should have) ambiguous truthiness, but all possible inhabitants of the other three types are always truthy. - As a structural type, `GeneralCallableType` can contain inner unions and intersections that must be sorted in some contexts in our internal model, but this is not true for the other three variants. This PR flattens `Type::Callable` into four distinct `Type::` variants. In the process, it fixes a number of latent bugs that were concealed by the current architecture but are laid bare by the refactor. Unit tests for these bugs are included in the PR. |
||
---|---|---|
.. | ||
resources | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
mdtest.py | ||
mdtest.py.lock |