[ty] Return CallableType from BoundMethodType.into_callable_type (#19193)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run

This commit is contained in:
Matthew Mckee 2025-07-08 20:33:43 +01:00 committed by GitHub
parent 5eb5ec987d
commit 05139a323b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View file

@ -1104,7 +1104,9 @@ impl<'db> Type<'db> {
Type::FunctionLiteral(function_literal) => { Type::FunctionLiteral(function_literal) => {
Some(Type::Callable(function_literal.into_callable_type(db))) 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(_) => { Type::NominalInstance(_) | Type::ProtocolInstance(_) => {
let call_symbol = self let call_symbol = self
@ -7166,8 +7168,8 @@ fn walk_bound_method_type<'db, V: visitor::TypeVisitor<'db> + ?Sized>(
} }
impl<'db> BoundMethodType<'db> { impl<'db> BoundMethodType<'db> {
pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> Type<'db> { pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
Type::Callable(CallableType::new( CallableType::new(
db, db,
CallableSignature::from_overloads( CallableSignature::from_overloads(
self.function(db) self.function(db)
@ -7177,7 +7179,7 @@ impl<'db> BoundMethodType<'db> {
.map(signatures::Signature::bind_self), .map(signatures::Signature::bind_self),
), ),
false, false,
)) )
} }
fn normalized_impl(self, db: &'db dyn Db, visitor: &mut TypeTransformer<'db>) -> Self { fn normalized_impl(self, db: &'db dyn Db, visitor: &mut TypeTransformer<'db>) -> Self {

View file

@ -602,7 +602,7 @@ impl<'db> ClassType<'db> {
// https://typing.python.org/en/latest/spec/constructors.html#converting-a-constructor-to-callable // 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 // by always respecting the signature of the metaclass `__call__`, rather than
// using a heuristic which makes unwarranted assumptions to sometimes ignore it. // 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 let dunder_new_function_symbol = self_ty

View file

@ -766,7 +766,7 @@ impl<'db> FunctionType<'db> {
self.literal(db).signature(db, self.type_mappings(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> { pub(crate) fn into_callable_type(self, db: &'db dyn Db) -> CallableType<'db> {
CallableType::new(db, self.signature(db), false) CallableType::new(db, self.signature(db), false)
} }