mirror of https://github.com/astral-sh/ruff
[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:
parent
98df62db79
commit
ef1802b94f
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue