Skip to content

Commit 20e1240

Browse files
committed
adjust intersection notes, call for simplfying unions
1 parent a6ba861 commit 20e1240

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎peps/pep-0827.rst‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ Union processing
665665
* ``FromUnion[T]``: Returns a tuple containing all of the union
666666
elements, or a 1-ary tuple containing T if it is not a union.
667667

668+
The union should first be simplified by removing elements that are
669+
subtypes of other elements, but *not* by replacing ``Literal[True,
670+
False]`` with ``bool`` or vice-versa or similar.
671+
668672
The goal here is to make it possible to lift operations over
669673
unions. Care ought to be taken when using this, since the particular
670674
order of elements is not specified; typically the result should be
@@ -1856,10 +1860,14 @@ Open Issues
18561860
Arguably, though, we would like ``tuple[Any | None, ...]`` as the result,
18571861
which would require some more careful thought to specify.
18581862

1859-
* Would adding intersection types conflict with any of this, if they
1860-
are added? Would it be sufficient to add ``FromIntersection`` to
1861-
deal with it, in addition to specifying how the existing operators
1862-
should handle it?
1863+
* Would intersection types conflict with any of this, if they are
1864+
added? Would it be sufficient to just specify how existing operators
1865+
should handle it (probably including that intersections should be
1866+
distributed over unions when doing ``FromUnion``, I'd guess, like TS
1867+
does for conditional types)? We could potentially add
1868+
``FromIntersection``, but intersections simplify aggressively and it
1869+
is not clear it would be sensical. TypeScript does not have an
1870+
equivalent.
18631871

18641872
* Should ``GetMemberType`` follow the descriptor protocol,
18651873
``__getattr__``, etc? (Currently the behavior is for it to

0 commit comments

Comments
 (0)