mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 07:34:06 -05:00
[ty] Repurpose FunctionType.into_bound_method_type to return BoundMethodType (#19793)
## Summary As per our naming scheme (at least for callable types) this should return a `BoundMethodType`, or be renamed, but it makes more sense to change the return type. I also ensure `ClassType.into_callable` returns a `Type::Callable` in the changed branch. Ideally we could return a `CallableType` from these `into_callable` functions (and rename to `into_callable_type` but because of unions we cannot do this.
This commit is contained in:
@@ -1044,7 +1044,11 @@ impl<'db> ClassType<'db> {
|
||||
.place;
|
||||
|
||||
if let Place::Type(Type::FunctionLiteral(new_function), _) = new_function_symbol {
|
||||
new_function.into_bound_method_type(db, self_ty)
|
||||
Type::Callable(
|
||||
new_function
|
||||
.into_bound_method_type(db, self_ty)
|
||||
.into_callable_type(db),
|
||||
)
|
||||
} else {
|
||||
// Fallback if no `object.__new__` is found.
|
||||
CallableType::single(
|
||||
|
||||
@@ -800,13 +800,13 @@ impl<'db> FunctionType<'db> {
|
||||
CallableType::new(db, self.signature(db), false)
|
||||
}
|
||||
|
||||
/// Convert the `FunctionType` into a [`Type::BoundMethod`].
|
||||
/// Convert the `FunctionType` into a [`BoundMethodType`].
|
||||
pub(crate) fn into_bound_method_type(
|
||||
self,
|
||||
db: &'db dyn Db,
|
||||
self_instance: Type<'db>,
|
||||
) -> Type<'db> {
|
||||
Type::BoundMethod(BoundMethodType::new(db, self, self_instance))
|
||||
) -> BoundMethodType<'db> {
|
||||
BoundMethodType::new(db, self, self_instance)
|
||||
}
|
||||
|
||||
pub(crate) fn has_relation_to(
|
||||
|
||||
Reference in New Issue
Block a user