@@ -94,6 +94,7 @@ mod infer;
94
94
mod instance;
95
95
mod mro;
96
96
mod narrow;
97
+ mod open_calls;
97
98
mod protocol_class;
98
99
mod signatures;
99
100
mod special_form;
@@ -3446,6 +3447,11 @@ impl<'db> Type<'db> {
3446
3447
Type :: KnownBoundMethod ( KnownBoundMethodType :: StrStartswith ( literal) ) ,
3447
3448
)
3448
3449
. into ( ) ,
3450
+ Type :: NominalInstance ( instance)
3451
+ if instance. has_known_class ( db, KnownClass :: Path ) && name == "open" =>
3452
+ {
3453
+ Place :: bound ( Type :: KnownBoundMethod ( KnownBoundMethodType :: PathOpen ) ) . into ( )
3454
+ }
3449
3455
3450
3456
Type :: ClassLiteral ( class)
3451
3457
if name == "__get__" && class. is_known ( db, KnownClass :: FunctionType ) =>
@@ -6171,7 +6177,7 @@ impl<'db> Type<'db> {
6171
6177
| Type :: AlwaysTruthy
6172
6178
| Type :: AlwaysFalsy
6173
6179
| Type :: WrapperDescriptor ( _)
6174
- | Type :: KnownBoundMethod ( KnownBoundMethodType :: StrStartswith ( _) )
6180
+ | Type :: KnownBoundMethod ( KnownBoundMethodType :: StrStartswith ( _) | KnownBoundMethodType :: PathOpen )
6175
6181
| Type :: DataclassDecorator ( _)
6176
6182
| Type :: DataclassTransformer ( _)
6177
6183
// A non-generic class never needs to be specialized. A generic class is specialized
@@ -6316,7 +6322,9 @@ impl<'db> Type<'db> {
6316
6322
| Type :: AlwaysTruthy
6317
6323
| Type :: AlwaysFalsy
6318
6324
| Type :: WrapperDescriptor ( _)
6319
- | Type :: KnownBoundMethod ( KnownBoundMethodType :: StrStartswith ( _) )
6325
+ | Type :: KnownBoundMethod (
6326
+ KnownBoundMethodType :: StrStartswith ( _) | KnownBoundMethodType :: PathOpen ,
6327
+ )
6320
6328
| Type :: DataclassDecorator ( _)
6321
6329
| Type :: DataclassTransformer ( _)
6322
6330
| Type :: ModuleLiteral ( _)
@@ -9397,6 +9405,8 @@ pub enum KnownBoundMethodType<'db> {
9397
9405
/// this allows us to understand statically known branches for common tests such as
9398
9406
/// `if sys.platform.startswith("freebsd")`.
9399
9407
StrStartswith ( StringLiteralType < ' db > ) ,
9408
+ /// Method wrapper for `Path.open`,
9409
+ PathOpen ,
9400
9410
}
9401
9411
9402
9412
pub ( super ) fn walk_method_wrapper_type < ' db , V : visitor:: TypeVisitor < ' db > + ?Sized > (
@@ -9420,6 +9430,7 @@ pub(super) fn walk_method_wrapper_type<'db, V: visitor::TypeVisitor<'db> + ?Size
9420
9430
KnownBoundMethodType :: StrStartswith ( string_literal) => {
9421
9431
visitor. visit_type ( db, Type :: StringLiteral ( string_literal) ) ;
9422
9432
}
9433
+ KnownBoundMethodType :: PathOpen => { }
9423
9434
}
9424
9435
}
9425
9436
@@ -9455,17 +9466,23 @@ impl<'db> KnownBoundMethodType<'db> {
9455
9466
ConstraintSet :: from ( self == other)
9456
9467
}
9457
9468
9469
+ ( KnownBoundMethodType :: PathOpen , KnownBoundMethodType :: PathOpen ) => {
9470
+ ConstraintSet :: from ( true )
9471
+ }
9472
+
9458
9473
(
9459
9474
KnownBoundMethodType :: FunctionTypeDunderGet ( _)
9460
9475
| KnownBoundMethodType :: FunctionTypeDunderCall ( _)
9461
9476
| KnownBoundMethodType :: PropertyDunderGet ( _)
9462
9477
| KnownBoundMethodType :: PropertyDunderSet ( _)
9463
- | KnownBoundMethodType :: StrStartswith ( _) ,
9478
+ | KnownBoundMethodType :: StrStartswith ( _)
9479
+ | KnownBoundMethodType :: PathOpen ,
9464
9480
KnownBoundMethodType :: FunctionTypeDunderGet ( _)
9465
9481
| KnownBoundMethodType :: FunctionTypeDunderCall ( _)
9466
9482
| KnownBoundMethodType :: PropertyDunderGet ( _)
9467
9483
| KnownBoundMethodType :: PropertyDunderSet ( _)
9468
- | KnownBoundMethodType :: StrStartswith ( _) ,
9484
+ | KnownBoundMethodType :: StrStartswith ( _)
9485
+ | KnownBoundMethodType :: PathOpen ,
9469
9486
) => ConstraintSet :: from ( false ) ,
9470
9487
}
9471
9488
}
@@ -9500,17 +9517,23 @@ impl<'db> KnownBoundMethodType<'db> {
9500
9517
ConstraintSet :: from ( self == other)
9501
9518
}
9502
9519
9520
+ ( KnownBoundMethodType :: PathOpen , KnownBoundMethodType :: PathOpen ) => {
9521
+ ConstraintSet :: from ( true )
9522
+ }
9523
+
9503
9524
(
9504
9525
KnownBoundMethodType :: FunctionTypeDunderGet ( _)
9505
9526
| KnownBoundMethodType :: FunctionTypeDunderCall ( _)
9506
9527
| KnownBoundMethodType :: PropertyDunderGet ( _)
9507
9528
| KnownBoundMethodType :: PropertyDunderSet ( _)
9508
- | KnownBoundMethodType :: StrStartswith ( _) ,
9529
+ | KnownBoundMethodType :: StrStartswith ( _)
9530
+ | KnownBoundMethodType :: PathOpen ,
9509
9531
KnownBoundMethodType :: FunctionTypeDunderGet ( _)
9510
9532
| KnownBoundMethodType :: FunctionTypeDunderCall ( _)
9511
9533
| KnownBoundMethodType :: PropertyDunderGet ( _)
9512
9534
| KnownBoundMethodType :: PropertyDunderSet ( _)
9513
- | KnownBoundMethodType :: StrStartswith ( _) ,
9535
+ | KnownBoundMethodType :: StrStartswith ( _)
9536
+ | KnownBoundMethodType :: PathOpen ,
9514
9537
) => ConstraintSet :: from ( false ) ,
9515
9538
}
9516
9539
}
@@ -9529,7 +9552,7 @@ impl<'db> KnownBoundMethodType<'db> {
9529
9552
KnownBoundMethodType :: PropertyDunderSet ( property) => {
9530
9553
KnownBoundMethodType :: PropertyDunderSet ( property. normalized_impl ( db, visitor) )
9531
9554
}
9532
- KnownBoundMethodType :: StrStartswith ( _) => self ,
9555
+ KnownBoundMethodType :: StrStartswith ( _) | KnownBoundMethodType :: PathOpen => self ,
9533
9556
}
9534
9557
}
9535
9558
@@ -9541,6 +9564,7 @@ impl<'db> KnownBoundMethodType<'db> {
9541
9564
| KnownBoundMethodType :: PropertyDunderGet ( _)
9542
9565
| KnownBoundMethodType :: PropertyDunderSet ( _) => KnownClass :: MethodWrapperType ,
9543
9566
KnownBoundMethodType :: StrStartswith ( _) => KnownClass :: BuiltinFunctionType ,
9567
+ KnownBoundMethodType :: PathOpen => KnownClass :: Path ,
9544
9568
}
9545
9569
}
9546
9570
@@ -9637,6 +9661,9 @@ impl<'db> KnownBoundMethodType<'db> {
9637
9661
Some ( KnownClass :: Bool . to_instance ( db) ) ,
9638
9662
) ) )
9639
9663
}
9664
+ KnownBoundMethodType :: PathOpen => {
9665
+ Either :: Right ( std:: iter:: once ( Signature :: todo ( "`Path.open` return type" ) ) )
9666
+ }
9640
9667
}
9641
9668
}
9642
9669
}
0 commit comments