Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Union[A,B] type hint yields [user class A, user class B] instead of [instance A, instance B] #459

Closed
lostmsu opened this issue Dec 5, 2018 · 1 comment
Milestone

Comments

@lostmsu
Copy link
Contributor

lostmsu commented Dec 5, 2018

Subj.

from typing import Union
class A:
  pass
class B:
  pass
def a() -> Union[A,B]: ...
def b() -> A: ...

Analysis of a's return type gives back a set of user class A and user class B, whereas it should be instance A and instance B.
For comparison, analysis of b's return type gives back a set of instance A.

lostmsu added a commit to losttech/PLS that referenced this issue Jan 5, 2019
lostmsu added a commit to losttech/PLS that referenced this issue Jan 5, 2019
@jakebailey
Copy link
Member

As of #546:

from typing import Union
class A:
    def __init__(self):
        self.a = 1234

class B:
    def __init__(self):
        self.b = "1234"

def a() -> Union[A,B]: ...
def b() -> A: ...

aa = a()
bb = b()

image

image

@jakebailey jakebailey added this to the Feb 2019.1 milestone Feb 14, 2019
lostmsu added a commit to losttech/PLS that referenced this issue Mar 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants