File tree Expand file tree Collapse file tree 5 files changed +234
-47
lines changed
crates/red_knot_python_semantic Expand file tree Collapse file tree 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:
77``` py
88import builtins
99
10- reveal_type(builtins.chr) # revealed: def chr(i: int | SupportsIndex, /) -> str
10+ reveal_type(builtins.chr) # revealed: def chr(i: SupportsIndex, /) -> str
1111```
1212
1313## Implicit use of builtin
1414
1515Or used implicitly:
1616
1717``` py
18- reveal_type(chr ) # revealed: def chr(i: int | SupportsIndex, /) -> str
18+ reveal_type(chr ) # revealed: def chr(i: SupportsIndex, /) -> str
1919reveal_type(str ) # revealed: Literal[str]
2020```
2121
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ if returns_bool():
1313 chr : int = 1
1414
1515def f ():
16- reveal_type(chr ) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str)
16+ reveal_type(chr ) # revealed: int | (def chr(i: SupportsIndex, /) -> str)
1717```
1818
1919## Conditionally global or builtin, with annotation
@@ -28,5 +28,5 @@ if returns_bool():
2828 chr : int = 1
2929
3030def f ():
31- reveal_type(chr ) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str)
31+ reveal_type(chr ) # revealed: int | (def chr(i: SupportsIndex, /) -> str)
3232```
Original file line number Diff line number Diff line change @@ -1448,38 +1448,6 @@ impl<'db> Type<'db> {
14481448 true
14491449 }
14501450
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-
14831451 ( Type :: NominalInstance ( self_instance) , Type :: NominalInstance ( target_instance) ) => {
14841452 self_instance. is_assignable_to ( db, target_instance)
14851453 }
You can’t perform that action at this time.
0 commit comments