@@ -3131,12 +3131,16 @@ impl<'db> Type<'db> {
31313131 ] ,
31323132 ) ) ,
31333133 Parameter :: positional_only ( Some ( Name :: new_static ( "start" ) ) )
3134- // TODO: SupportsIndex | None
3135- . with_annotated_type ( Type :: object ( db) )
3134+ . with_annotated_type ( UnionType :: from_elements (
3135+ db,
3136+ [ KnownClass :: SupportsIndex . to_instance ( db) , Type :: none ( db) ] ,
3137+ ) )
31363138 . with_default_type ( Type :: none ( db) ) ,
31373139 Parameter :: positional_only ( Some ( Name :: new_static ( "end" ) ) )
3138- // TODO: SupportsIndex | None
3139- . with_annotated_type ( Type :: object ( db) )
3140+ . with_annotated_type ( UnionType :: from_elements (
3141+ db,
3142+ [ KnownClass :: SupportsIndex . to_instance ( db) , Type :: none ( db) ] ,
3143+ ) )
31403144 . with_default_type ( Type :: none ( db) ) ,
31413145 ] ) ,
31423146 Some ( KnownClass :: Bool . to_instance ( db) ) ,
@@ -6188,7 +6192,11 @@ pub enum MethodWrapperKind<'db> {
61886192 PropertyDunderGet ( PropertyInstanceType < ' db > ) ,
61896193 /// Method wrapper for `some_property.__set__`
61906194 PropertyDunderSet ( PropertyInstanceType < ' db > ) ,
6191- /// Method wrapper for `str.startswith`
6195+ /// Method wrapper for `str.startswith`.
6196+ /// We treat this method specially because we want to be able to infer precise Boolean
6197+ /// literal return types if the instance and the prefix are both string literals, and
6198+ /// this allows us to understand statically known branches for common tests such as
6199+ /// `if sys.platform.startswith("freebsd")`.
61926200 StrStartswith ( StringLiteralType < ' db > ) ,
61936201}
61946202
0 commit comments