Skip to content

Commit 05139a3

Browse files
[ty] Return CallableType from BoundMethodType.into_callable_type (#19193)
1 parent 5eb5ec9 commit 05139a3

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,9 @@ impl<'db> Type<'db> {
11041104
Type::FunctionLiteral(function_literal) => {
11051105
Some(Type::Callable(function_literal.into_callable_type(db)))
11061106
}
1107-
Type::BoundMethod(bound_method) => Some(bound_method.into_callable_type(db)),
1107+
Type::BoundMethod(bound_method) => {
1108+
Some(Type::Callable(bound_method.into_callable_type(db)))
1109+
}
11081110

11091111
Type::NominalInstance(_) | Type::ProtocolInstance(_) => {
11101112
let call_symbol = self
@@ -7166,8 +7168,8 @@ fn walk_bound_method_type<'db, V: visitor::TypeVisitor<'db> + ?Sized>(
71667168
}
71677169

71687170
impl<'db> BoundMethodType<'db> {
7169-
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> Type<'db> {
7170-
Type::Callable(CallableType::new(
7171+
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
7172+
CallableType::new(
71717173
db,
71727174
CallableSignature::from_overloads(
71737175
self.function(db)
@@ -7177,7 +7179,7 @@ impl<'db> BoundMethodType<'db> {
71777179
.map(signatures::Signature::bind_self),
71787180
),
71797181
false,
7180-
))
7182+
)
71817183
}
71827184

71837185
fn normalized_impl(self, db: &'db dyn Db, visitor: &mut TypeTransformer<'db>) -> Self {

crates/ty_python_semantic/src/types/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ impl<'db> ClassType<'db> {
602602
// https://typing.python.org/en/latest/spec/constructors.html#converting-a-constructor-to-callable
603603
// by always respecting the signature of the metaclass `__call__`, rather than
604604
// using a heuristic which makes unwarranted assumptions to sometimes ignore it.
605-
return metaclass_dunder_call_function.into_callable_type(db);
605+
return Type::Callable(metaclass_dunder_call_function.into_callable_type(db));
606606
}
607607

608608
let dunder_new_function_symbol = self_ty

crates/ty_python_semantic/src/types/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'db> FunctionType<'db> {
766766
self.literal(db).signature(db, self.type_mappings(db))
767767
}
768768

769-
/// Convert the `FunctionType` into a [`Type::Callable`].
769+
/// Convert the `FunctionType` into a [`CallableType`].
770770
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
771771
CallableType::new(db, self.signature(db), false)
772772
}

0 commit comments

Comments
 (0)