Skip to content

Instantly share code, notes, and snippets.

@LordAmit
Last active January 18, 2018 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LordAmit/149ac3af847d72225c3585df5c91c25b to your computer and use it in GitHub Desktop.
Save LordAmit/149ac3af847d72225c3585df5c91c25b to your computer and use it in GitHub Desktop.
from typing import Union
class A():
a: int = 0
b: int = 0
class B():
a: int = 0
b: int = 0
def a_function(variable: Union[A, B]):
print("class provided is " + str(variable))
my_shortcut_union_type = Union[A, B]
def a_function_(variable: my_shortcut_union_type):
print("provided is " + str(variable))
a_function(A) # ERROR
a = A()
a_function(a) # OKAY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment