[ty] Ensure that a function-literal type is always equivalent to itself by AlexWaygood · Pull Request #18227 · astral-sh/ruff (original) (raw)

Summary

This is a short-term fix to some of our type-equivalence logic for function-literal and bound-method types. The issue was that two Callable types will not be considered equivalent if any parameter in either type is unannotated (and it is obviously very common in methods for the self parameter to be unannotated!). Following 97058e8, equivalence of two FunctionLiteral types defers to equivalence of the CallableType supertypes of the two function-literal types.

Long-term, we should clarify this situation by splitting FunctionLiteral into two separate variants, as described by @dcreager in astral-sh/ty#459 (comment) and astral-sh/ty#462

Closes astral-sh/ty#459

Test Plan