[ty] Ensure that a function-literal type is always equivalent to itself #18227
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Callabletypes will not be considered equivalent if any parameter in either type is unannotated (and it is obviously very common in methods for theselfparameter to be unannotated!). Following 97058e8, equivalence of twoFunctionLiteraltypes defers to equivalence of theCallableTypesupertypes of the two function-literal types.Long-term, we should clarify this situation by splitting
FunctionLiteralinto two separate variants, as described by @dcreager in astral-sh/ty#459 (comment) and astral-sh/ty#462Closes astral-sh/ty#459
Test Plan
cargo test -p ty_python_semanticQUICKCHECK_TESTS=100000 cargo test --release -p ty_python_semantic -- --ignored types::property_tests::stable