Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions
Description
I noticed some rather erratic behavior when sometimes it picks union and other times the join.
fromtypingimportIterableclassA: ... classB: ... classC: ... defupcast[T](arg: Iterable[T]) ->Iterable[T]: returnargdeftest_builtin(x: tuple[int, str, None]) ->None: reveal_type(upcast(x)) # Iterable[str | int | None]deftest_custom(x: tuple[A, B, C]) ->None: reveal_type(upcast(x)) # Iterable[object]deftest_mixed1(x: tuple[A, str, None]) ->None: reveal_type(upcast(x)) # Iterable[str | A | None]deftest_mixed2(x: tuple[int, str, C]) ->None: reveal_type(upcast(x)) # Iterable[object]https://mypy-play.net/?mypy=latest&python=3.12&gist=833674a36174c4140a89645b609da8a9
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions