File tree 5 files changed +234
-47
lines changed
crates/red_knot_python_semantic
5 files changed +234
-47
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,15 @@ Builtin symbols can be explicitly imported:
7
7
``` py
8
8
import builtins
9
9
10
- reveal_type(builtins.chr) # revealed: def chr(i: int | SupportsIndex, /) -> str
10
+ reveal_type(builtins.chr) # revealed: def chr(i: SupportsIndex, /) -> str
11
11
```
12
12
13
13
## Implicit use of builtin
14
14
15
15
Or used implicitly:
16
16
17
17
``` py
18
- reveal_type(chr ) # revealed: def chr(i: int | SupportsIndex, /) -> str
18
+ reveal_type(chr ) # revealed: def chr(i: SupportsIndex, /) -> str
19
19
reveal_type(str ) # revealed: Literal[str]
20
20
```
21
21
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ if returns_bool():
13
13
chr : int = 1
14
14
15
15
def f ():
16
- reveal_type(chr ) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str)
16
+ reveal_type(chr ) # revealed: int | (def chr(i: SupportsIndex, /) -> str)
17
17
```
18
18
19
19
## Conditionally global or builtin, with annotation
@@ -28,5 +28,5 @@ if returns_bool():
28
28
chr : int = 1
29
29
30
30
def f ():
31
- reveal_type(chr ) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str)
31
+ reveal_type(chr ) # revealed: int | (def chr(i: SupportsIndex, /) -> str)
32
32
```
Original file line number Diff line number Diff line change @@ -1448,38 +1448,6 @@ impl<'db> Type<'db> {
1448
1448
true
1449
1449
}
1450
1450
1451
- // TODO: This is a workaround to avoid false positives (e.g. when checking function calls
1452
- // with `SupportsIndex` parameters), which should be removed when we understand protocols.
1453
- ( lhs, Type :: NominalInstance ( instance) )
1454
- if instance. class ( ) . is_known ( db, KnownClass :: SupportsIndex ) =>
1455
- {
1456
- match lhs {
1457
- Type :: NominalInstance ( instance)
1458
- if matches ! (
1459
- instance. class( ) . known( db) ,
1460
- Some ( KnownClass :: Int | KnownClass :: SupportsIndex )
1461
- ) =>
1462
- {
1463
- true
1464
- }
1465
- Type :: IntLiteral ( _) => true ,
1466
- _ => false ,
1467
- }
1468
- }
1469
-
1470
- // TODO: ditto for avoiding false positives when checking function calls with `Sized` parameters.
1471
- ( lhs, Type :: NominalInstance ( instance) )
1472
- if instance. class ( ) . is_known ( db, KnownClass :: Sized ) =>
1473
- {
1474
- matches ! (
1475
- lhs. to_meta_type( db) . member( db, "__len__" ) ,
1476
- SymbolAndQualifiers {
1477
- symbol: Symbol :: Type ( ..) ,
1478
- ..
1479
- }
1480
- )
1481
- }
1482
-
1483
1451
( Type :: NominalInstance ( self_instance) , Type :: NominalInstance ( target_instance) ) => {
1484
1452
self_instance. is_assignable_to ( db, target_instance)
1485
1453
}
You can’t perform that action at this time.
0 commit comments