Skip to content

Commit 3637128

Browse files
committed
a bit more explicit discussion
1 parent 2f6b9f1 commit 3637128

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

peps/pep-0827.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ which produce aliases that have some dunder methods overloaded for
588588
Many of the operators specified have type bounds listed for some of
589589
their operands. These should be interpreted more as documentation than
590590
as exact type bounds. Trying to evaluate operators with invalid
591-
arguments will produce an error. (There is some
591+
arguments will produce an error. When this happens, the value of the
592+
failed operator is ``Any``, so that downstream evaluation does not
593+
cascade further errors. (There is some
592594
discussion of potential alternatives :ref:`below <pep827-strict-kinds>`.)
593595

594596
Note that in some of these bounds below we write things like
@@ -628,6 +630,8 @@ Basic operators
628630
``GetArg[A, B, Literal[0]] == C``
629631
while ``GetArg[A, A, Literal[0]]`` is a type error).
630632

633+
If ``T`` is ``Any``, the result is ``Any``.
634+
631635
Negative indexes work in the usual way.
632636

633637
(Note that runtime evaluators of type annotations are likely
@@ -644,12 +648,16 @@ Basic operators
644648
arguments of ``T`` when interpreted as ``Base``, or an error if it
645649
cannot be.
646650

651+
If ``T`` is ``Any``, the result is ``Any``.
652+
647653
* ``Length[T: tuple]`` - Gets the length of a tuple as an int literal
648654
(or ``Literal[None]`` if it is unbounded)
649655

650656
* ``Slice[S: tuple, Start: Literal[int | None], End: Literal[int | None]]``:
651657
Slices a tuple type.
652658

659+
If ``S`` is ``Any``, the result is ``Any``.
660+
653661
* ``GetSpecialAttr[T, Attr: Literal[str]]``: Extracts the value
654662
of the special attribute named ``Attr`` from the class ``T``. Valid
655663
attributes are ``__name__``, ``__module__``, and ``__qualname__``.
@@ -691,9 +699,13 @@ Object inspection
691699
* ``GetMember[T, S: Literal[str]]``: Produces a ``Member`` type for the
692700
member named ``S`` from the class ``T``, or an error if it does not exist.
693701

702+
If ``T`` is ``Any``, the result is ``Any``.
703+
694704
* ``GetMemberType[T, S: Literal[str]]``: Extract the type of the
695705
member named ``S`` from the class ``T``, or ``Never`` if it does not exist.
696706

707+
If ``T`` is ``Any``, the result is ``Any``.
708+
697709
* ``Member[N: Literal[str], T, Q: MemberQuals, Init, D]``: ``Member``,
698710
is a simple type, not an operator, that is used to describe members
699711
of classes. Its type parameters encode the information about each

0 commit comments

Comments
 (0)