diff --git a/crates/red_knot_python_semantic/resources/mdtest/import/builtins.md b/crates/red_knot_python_semantic/resources/mdtest/import/builtins.md index 1b2305fb41..7d1a3f5e0b 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/import/builtins.md +++ b/crates/red_knot_python_semantic/resources/mdtest/import/builtins.md @@ -7,7 +7,7 @@ Builtin symbols can be explicitly imported: ```py import builtins -reveal_type(builtins.chr) # revealed: def chr(i: int | SupportsIndex, /) -> str +reveal_type(builtins.chr) # revealed: def chr(i: SupportsIndex, /) -> str ``` ## Implicit use of builtin @@ -15,7 +15,7 @@ reveal_type(builtins.chr) # revealed: def chr(i: int | SupportsIndex, /) -> str Or used implicitly: ```py -reveal_type(chr) # revealed: def chr(i: int | SupportsIndex, /) -> str +reveal_type(chr) # revealed: def chr(i: SupportsIndex, /) -> str reveal_type(str) # revealed: Literal[str] ``` diff --git a/crates/red_knot_python_semantic/resources/mdtest/scopes/builtin.md b/crates/red_knot_python_semantic/resources/mdtest/scopes/builtin.md index 5aa4175f8e..fc2ca70f97 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/scopes/builtin.md +++ b/crates/red_knot_python_semantic/resources/mdtest/scopes/builtin.md @@ -13,7 +13,7 @@ if returns_bool(): chr: int = 1 def f(): - reveal_type(chr) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str) + reveal_type(chr) # revealed: int | (def chr(i: SupportsIndex, /) -> str) ``` ## Conditionally global or builtin, with annotation @@ -28,5 +28,5 @@ if returns_bool(): chr: int = 1 def f(): - reveal_type(chr) # revealed: int | (def chr(i: int | SupportsIndex, /) -> str) + reveal_type(chr) # revealed: int | (def chr(i: SupportsIndex, /) -> str) ``` diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index cee6b4c793..617cc3d2d6 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -1453,38 +1453,6 @@ impl<'db> Type<'db> { true } - // TODO: This is a workaround to avoid false positives (e.g. when checking function calls - // with `SupportsIndex` parameters), which should be removed when we understand protocols. - (lhs, Type::NominalInstance(instance)) - if instance.class().is_known(db, KnownClass::SupportsIndex) => - { - match lhs { - Type::NominalInstance(instance) - if matches!( - instance.class().known(db), - Some(KnownClass::Int | KnownClass::SupportsIndex) - ) => - { - true - } - Type::IntLiteral(_) => true, - _ => false, - } - } - - // TODO: ditto for avoiding false positives when checking function calls with `Sized` parameters. - (lhs, Type::NominalInstance(instance)) - if instance.class().is_known(db, KnownClass::Sized) => - { - matches!( - lhs.to_meta_type(db).member(db, "__len__"), - SymbolAndQualifiers { - symbol: Symbol::Type(..), - .. - } - ) - } - (Type::NominalInstance(self_instance), Type::NominalInstance(target_instance)) => { self_instance.is_assignable_to(db, target_instance) }