Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions crates/red_knot_python_semantic/src/types/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
Loading