diff --git a/crates/red_knot_python_semantic/resources/mdtest/annotations/annotated.md b/crates/red_knot_python_semantic/resources/mdtest/annotations/annotated.md index a9f7b91618..3fb2cc3138 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/annotations/annotated.md +++ b/crates/red_knot_python_semantic/resources/mdtest/annotations/annotated.md @@ -73,12 +73,10 @@ Inheriting from `Annotated[T, ...]` is equivalent to inheriting from `T` itself. ```py from typing_extensions import Annotated -# TODO: False positive -# error: [invalid-base] class C(Annotated[int, "foo"]): ... # TODO: Should be `tuple[Literal[C], Literal[int], Literal[object]]` -reveal_type(C.__mro__) # revealed: tuple[Literal[C], Unknown, Literal[object]] +reveal_type(C.__mro__) # revealed: tuple[Literal[C], @Todo(Inference of subscript on special form), Literal[object]] ``` ### Not parameterized diff --git a/crates/red_knot_python_semantic/src/types/class.rs b/crates/red_knot_python_semantic/src/types/class.rs index 0de0a2b38c..5ae487e725 100644 --- a/crates/red_knot_python_semantic/src/types/class.rs +++ b/crates/red_knot_python_semantic/src/types/class.rs @@ -851,6 +851,10 @@ impl<'db> KnownClass { matches!(self, Self::Bool) } + pub(crate) const fn is_special_form(self) -> bool { + matches!(self, Self::SpecialForm) + } + /// Determine whether instances of this class are always truthy, always falsy, /// or have an ambiguous truthiness. pub(crate) const fn bool(self) -> Truthiness { diff --git a/crates/red_knot_python_semantic/src/types/infer.rs b/crates/red_knot_python_semantic/src/types/infer.rs index ba07aefb2c..4b8936e7d5 100644 --- a/crates/red_knot_python_semantic/src/types/infer.rs +++ b/crates/red_knot_python_semantic/src/types/infer.rs @@ -5631,6 +5631,11 @@ impl<'db> TypeInferenceBuilder<'db> { (Type::KnownInstance(KnownInstanceType::Protocol), _) => { Type::Dynamic(DynamicType::TodoProtocol) } + (Type::KnownInstance(known_instance), _) + if known_instance.class().is_special_form() => + { + todo_type!("Inference of subscript on special form") + } (value_ty, slice_ty) => { // If the class defines `__getitem__`, return its return type. //