[red-knot] Add assignability of function literals to callables (#17095)

## Summary

Part  of #16953

## Test Plan

Update is_assignable_to.md

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
Matthew Mckee
2025-03-31 16:42:42 +01:00
committed by GitHub
parent 491a51960e
commit 4a6fa5fc27
2 changed files with 23 additions and 0 deletions

View File

@@ -900,6 +900,12 @@ impl<'db> Type<'db> {
Type::Callable(CallableType::General(target_callable)),
) => self_callable.is_assignable_to(db, target_callable),
(Type::FunctionLiteral(self_function_literal), Type::Callable(_)) => {
self_function_literal
.into_callable_type(db)
.is_assignable_to(db, target)
}
// TODO other types containing gradual forms (e.g. generics containing Any/Unknown)
_ => self.is_subtype_of(db, target),
}