@@ -2508,6 +2508,10 @@ impl<'db> Type<'db> {
25082508 Type :: MethodWrapper ( MethodWrapperKind :: PropertyDunderSet ( property) ) ,
25092509 )
25102510 . into ( ) ,
2511+ Type :: StringLiteral ( literal) if name == "startswith" => Symbol :: bound (
2512+ Type :: MethodWrapper ( MethodWrapperKind :: StrStartswith ( literal) ) ,
2513+ )
2514+ . into ( ) ,
25112515
25122516 Type :: ClassLiteral ( class)
25132517 if name == "__get__" && class. is_known ( db, KnownClass :: FunctionType ) =>
@@ -3112,6 +3116,34 @@ impl<'db> Type<'db> {
31123116 ) )
31133117 }
31143118
3119+ Type :: MethodWrapper ( MethodWrapperKind :: StrStartswith ( _) ) => {
3120+ Signatures :: single ( CallableSignature :: single (
3121+ self ,
3122+ Signature :: new (
3123+ Parameters :: new ( [
3124+ Parameter :: positional_only ( Some ( Name :: new_static ( "prefix" ) ) )
3125+ . with_annotated_type ( UnionType :: from_elements (
3126+ db,
3127+ [
3128+ KnownClass :: Str . to_instance ( db) ,
3129+ // TODO: tuple[str, ...]
3130+ KnownClass :: Tuple . to_instance ( db) ,
3131+ ] ,
3132+ ) ) ,
3133+ Parameter :: positional_only ( Some ( Name :: new_static ( "start" ) ) )
3134+ // TODO: SupportsIndex | None
3135+ . with_annotated_type ( Type :: object ( db) )
3136+ . with_default_type ( Type :: none ( db) ) ,
3137+ Parameter :: positional_only ( Some ( Name :: new_static ( "end" ) ) )
3138+ // TODO: SupportsIndex | None
3139+ . with_annotated_type ( Type :: object ( db) )
3140+ . with_default_type ( Type :: none ( db) ) ,
3141+ ] ) ,
3142+ Some ( KnownClass :: Bool . to_instance ( db) ) ,
3143+ ) ,
3144+ ) )
3145+ }
3146+
31153147 Type :: FunctionLiteral ( function_type) => match function_type. known ( db) {
31163148 Some (
31173149 KnownFunction :: IsEquivalentTo
@@ -4238,6 +4270,7 @@ impl<'db> Type<'db> {
42384270 | Type :: AlwaysTruthy
42394271 | Type :: AlwaysFalsy
42404272 | Type :: WrapperDescriptor ( _)
4273+ | Type :: MethodWrapper ( MethodWrapperKind :: StrStartswith ( _) )
42414274 | Type :: ModuleLiteral ( _)
42424275 // A non-generic class never needs to be specialized. A generic class is specialized
42434276 // explicitly (via a subscript expression) or implicitly (via a call), and not because
@@ -6155,6 +6188,8 @@ pub enum MethodWrapperKind<'db> {
61556188 PropertyDunderGet ( PropertyInstanceType < ' db > ) ,
61566189 /// Method wrapper for `some_property.__set__`
61576190 PropertyDunderSet ( PropertyInstanceType < ' db > ) ,
6191+ /// Method wrapper for `str.startswith`
6192+ StrStartswith ( StringLiteralType < ' db > ) ,
61586193}
61596194
61606195/// Represents a specific instance of `types.WrapperDescriptorType`
0 commit comments