[ty] Treat functions, methods, and dynamic types as function-like Callables (#20842)

## Summary

Treat functions, methods, and dynamic types as function-like `Callable`s

closes https://github.com/astral-sh/ty/issues/1342
closes https://github.com/astral-sh/ty/issues/1344

## Ecosystem analysis

All removed diagnostics look like cases of
https://github.com/astral-sh/ty/issues/1344

## Test Plan

Added regression test
This commit is contained in:
David Peter 2025-10-13 15:21:55 +02:00 committed by GitHub
parent 513d2996ec
commit 195e8f0684
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 101 additions and 19 deletions

View file

@ -1401,7 +1401,7 @@ impl<'db> Type<'db> {
match self {
Type::Callable(_) => Some(self),
Type::Dynamic(_) => Some(CallableType::single(db, Signature::dynamic(self))),
Type::Dynamic(_) => Some(CallableType::function_like(db, Signature::dynamic(self))),
Type::FunctionLiteral(function_literal) => {
Some(Type::Callable(function_literal.into_callable_type(db)))
@ -9770,7 +9770,7 @@ impl<'db> BoundMethodType<'db> {
.iter()
.map(|signature| signature.bind_self(db, Some(self_instance))),
),
false,
true,
)
}

View file

@ -943,7 +943,7 @@ impl<'db> FunctionType<'db> {
/// Convert the `FunctionType` into a [`CallableType`].
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
CallableType::new(db, self.signature(db), false)
CallableType::new(db, self.signature(db), true)
}
/// Convert the `FunctionType` into a [`BoundMethodType`].