Skip to content

Commit 2705b53

Browse files
committed
don't state that type[Callable] is invalid
1 parent 7f8f6bb commit 2705b53

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

conformance/tests/specialtypes_type.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#type
66

77

8-
from typing import Any, Callable, Generic, Type, TypeAlias, TypeVar, assert_type
8+
from typing import Any, Callable, Generic, Type, TypeAlias, TypeVar, assert_type, Literal, TypedDict
99

1010

1111
class User:
@@ -173,3 +173,8 @@ def func13(v: type):
173173
class ClassA(Generic[T]):
174174
def method1(self, v: type) -> type[T]:
175175
return v # OK
176+
177+
# > Some other special forms like Literal and TypedDict are not allowed as an argument to type.
178+
_: type[Callable] # OK
179+
_: type[TypedDict] # E
180+
_: type[Literal[1]] # E

docs/spec/special-types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ concrete class object, e.g. in the above example::
188188
``type[T]`` where ``T`` is a type variable is allowed when annotating the
189189
first argument of a class method (see the relevant section).
190190

191-
Any other :term:`special forms <special form>` like ``Callable`` are not
192-
allowed as an argument to ``type``.
191+
Some other :term:`special forms <special form>` like ``Literal`` and
192+
`TypedDict` are not allowed as an argument to ``type``.
193193

194194
There are some concerns with this feature: for example when
195195
``new_user()`` calls ``user_class()`` this implies that all subclasses

0 commit comments

Comments
 (0)