ruff/crates/ty_python_semantic/resources/mdtest/call
Carl Meyer 0b181bc2ad
Fix instance vs callable subtyping/assignability (#18260)
## Summary

Fix some issues with subtying/assignability for instances vs callables.
We need to look up dunders on the class, not the instance, and we should
limit our logic here to delegating to the type of `__call__`, so it
doesn't get out of sync with the calls we allow.

Also, we were just entirely missing assignability handling for
`__call__` implemented as anything other than a normal bound method
(though we had it for subtyping.)

A first step towards considering what else we want to change in
https://github.com/astral-sh/ty/issues/491

## Test Plan

mdtests

---------

Co-authored-by: med <medioqrity@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-05-22 19:47:05 +00:00
..
annotation.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
builtins.md [ty] Understand homogeneous tuple annotations (#17998) 2025-05-12 22:02:25 -04:00
callable_instance.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
constructor.md [ty] Rename call-possibly-unbound-method to possibly-unbound-implicit-call (#18017) 2025-05-22 15:25:51 +00:00
dunder.md Fix instance vs callable subtyping/assignability (#18260) 2025-05-22 19:47:05 +00:00
function.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
getattr_static.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
invalid_syntax.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
methods.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00
never.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
str_startswith.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
subclass_of.md [ty] Include synthesized arguments in displayed counts for too-many-positional-arguments (#18098) 2025-05-14 22:51:23 -04:00
union.md ty_python_semantic: add union type context to function call type errors 2025-05-09 13:40:51 -04:00