Skip to content

Instantly share code, notes, and snippets.

@LordAmit
Last active January 18, 2018 09:37
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/ac9dd309903421de6bb46eab43c6c0e0 to your computer and use it in GitHub Desktop.
Save LordAmit/ac9dd309903421de6bb46eab43c6c0e0 to your computer and use it in GitHub Desktop.
from typing import Union
from typing import Type
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 = Type[Union[A, B]]
def a_function_(variable: my_shortcut_union_type):
print("provided is " + str(variable))
a_function_(A) # Okay
a = A()
a_function(a) # OKAY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment