mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 10:26:26 +00:00
[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:
parent
513d2996ec
commit
195e8f0684
6 changed files with 101 additions and 19 deletions
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue