Skip to content

Commit a543533

Browse files
authored
[red-knot] Add failing test for use of type[] as a base class (#14913)
We support using `typing.Type[]` as a base class (and we have tests for it), but not yet `builtins.type[]`. At some point we should fix that, but I don't think it';s worth spending much time on now (and it might be easier once we've implemented generics?). This PR just adds a failing test with a TODO.
1 parent ef153a0 commit a543533

File tree

1 file changed

+11
-0
lines changed
  • crates/red_knot_python_semantic/resources/mdtest/type_of

1 file changed

+11
-0
lines changed

crates/red_knot_python_semantic/resources/mdtest/type_of/basic.md

+11
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,14 @@ class B: ...
133133
# error: [invalid-type-form]
134134
_: type[A, B]
135135
```
136+
137+
## As a base class
138+
139+
```py
140+
# TODO: this is a false positive
141+
# error: [invalid-base] "Invalid class base with type `GenericAlias` (all bases must be a class, `Any`, `Unknown` or `Todo`)"
142+
class Foo(type[int]): ...
143+
144+
# TODO: should be `tuple[Literal[Foo], Literal[type], Literal[object]]
145+
reveal_type(Foo.__mro__) # revealed: tuple[Literal[Foo], Unknown, Literal[object]]
146+
```

0 commit comments

Comments
 (0)