Skip to content

Commit f66ff99

Browse files
committed
Notes on UpdateClass
1 parent 86b122e commit f66ff99

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pep.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,18 @@ base classes and type decorators that do ``dataclass`` like things.
875875
This can only be used in the return type of a type decorator
876876
or as the return type of ``__init_subclass__``.
877877

878+
When a class is declared, if one or more of its ancestors have an
879+
``__init_subclass__`` with an ``UpdateClass`` return type, they are
880+
applied in reverse MRO order. N.B: If the ``cls`` param is
881+
parameterized by ``type[T]]``, then the class type should
882+
substituted in for ``T``.
883+
878884
One snag here: it introduces type-evaluation-order dependence; if the
879885
``UpdateClass`` return type for some ``__init_subclass__`` inspects
880886
some unrelated class's ``Members`` , and that class also has an
881-
``__init_subclass__``, then the results might depend on what order they
882-
are evaluated.
887+
``__init_subclass__``, then the results might depend on what order
888+
they are evaluated. Ideally this kind of case would be rejected,
889+
which I think ought to be possible?
883890

884891
This does actually exactly mirror a potential **runtime**
885892
evaluation-order dependence, though.

0 commit comments

Comments
 (0)