Skip to content

Commit 498e503

Browse files
committed
Address review comments: fix Any/subtype claim and clarify type[Never]
1 parent 290d119 commit 498e503

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

docs/spec/special-types.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ to a variable of any type ``T``::
117117
v1: int = x # OK — Never is a subtype of int
118118
v2: str = x # OK — Never is a subtype of str
119119

120-
No type other than ``Never`` itself (and :ref:`Any <any>`) is a subtype of
121-
``Never``. In particular, ``object`` is *not* a subtype of ``Never``::
120+
No type other than ``Never`` itself is a subtype of ``Never``. In
121+
particular, ``object`` is *not* a subtype of ``Never``::
122122

123123
def g(x: object) -> Never:
124124
return x # Error — object is not assignable to Never
@@ -162,9 +162,10 @@ apply: ``Container[Never]`` is only assignable to ``Container[Never]``::
162162
``type[Never]``
163163
^^^^^^^^^^^^^^^^^
164164

165-
``type[Never]`` represents the class object for a type that has no instances.
166-
In practice this type is rarely useful directly, but it is the correct result
167-
of narrowing a ``type[T]`` variable to an impossible branch.
165+
``type[Never]`` is a subtype of ``type[T]`` for every type ``T``, just as
166+
``Never`` is a subtype of every type ``T``. In practice a variable receives
167+
this type only in provably unreachable code — for example, when narrowing a
168+
``type[int] | type[str]`` through all possible branches.
168169

169170
.. _`numeric-promotions`:
170171

0 commit comments

Comments
 (0)