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

Description

@lostmsu

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.

Activity

  1. jakebailey commented on Feb 8, 2019

    @jakebailey
    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions