Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions crates/ty_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,9 @@ impl<'db> Type<'db> {
Type::FunctionLiteral(function_literal) => {
Some(Type::Callable(function_literal.into_callable_type(db)))
}
Type::BoundMethod(bound_method) => Some(bound_method.into_callable_type(db)),
Type::BoundMethod(bound_method) => {
Some(Type::Callable(bound_method.into_callable_type(db)))
}

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

impl<'db> BoundMethodType<'db> {
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> Type<'db> {
Type::Callable(CallableType::new(
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
CallableType::new(
db,
CallableSignature::from_overloads(
self.function(db)
Expand All @@ -7177,7 +7179,7 @@ impl<'db> BoundMethodType<'db> {
.map(signatures::Signature::bind_self),
),
false,
))
)
}

fn normalized_impl(self, db: &'db dyn Db, visitor: &mut TypeTransformer<'db>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_python_semantic/src/types/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ impl<'db> ClassType<'db> {
// https://typing.python.org/en/latest/spec/constructors.html#converting-a-constructor-to-callable
// by always respecting the signature of the metaclass `__call__`, rather than
// using a heuristic which makes unwarranted assumptions to sometimes ignore it.
return metaclass_dunder_call_function.into_callable_type(db);
return Type::Callable(metaclass_dunder_call_function.into_callable_type(db));
}

let dunder_new_function_symbol = self_ty
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_python_semantic/src/types/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ impl<'db> FunctionType<'db> {
self.literal(db).signature(db, self.type_mappings(db))
}

/// Convert the `FunctionType` into a [`Type::Callable`].
/// 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)
}
Expand Down
Loading