diff --git a/peps/pep-0827.rst b/peps/pep-0827.rst index 656c0ea7299..1dbf95d4031 100644 --- a/peps/pep-0827.rst +++ b/peps/pep-0827.rst @@ -665,6 +665,15 @@ Union processing * ``FromUnion[T]``: Returns a tuple containing all of the union elements, or a 1-ary tuple containing T if it is not a union. + The union should first be simplified by removing elements that are + subtypes of other elements, but *not* by replacing ``Literal[True, + False]`` with ``bool`` or vice-versa or similar. + + The goal here is to make it possible to lift operations over + unions. Care ought to be taken when using this, since the particular + order of elements is not specified; typically the result of the iteration + should be unpacked into another union immediately. + * ``Union[*Ts]``: ``Union`` will become able to take variadic arguments, so that it can take unpacked comprehension arguments. @@ -677,6 +686,11 @@ Object inspection * ``Members[T]``: produces a ``tuple`` of ``Member`` types describing the members (attributes and methods) of class or typed dict ``T``. + Properties should be returned as ``property`` types, which we should + make generic and parameterized over both the getter and setter + types. (Under discussion in `typeshed issue #4731 + `__) + In order to allow typechecking time and runtime evaluation to coincide more closely, **only members with explicit type annotations are included**. (This is intended to also exclude unannotated @@ -1846,6 +1860,19 @@ Open Issues Arguably, though, we would like ``tuple[Any | None, ...]`` as the result, which would require some more careful thought to specify. +* Would intersection types conflict with any of this, if they are + added? Would it be sufficient to just specify how existing operators + should handle it (probably including that intersections should be + distributed over unions when doing ``FromUnion``, I'd guess, like TS + does for conditional types)? We could potentially add + ``FromIntersection``, but intersections simplify aggressively and it + is not clear it would be sensical. TypeScript does not have an + equivalent. + +* Should ``GetMemberType`` follow the descriptor protocol, + ``__getattr__``, etc? (Currently the behavior is for it to + behave mostly like ``GetMember[T, S].type``.) + Acknowledgements ================