How to do python typing for list of classes.
Suppose I have following classes.
from dataclasses import dataclass
@dataclass
class A:
name: str
@dataclass
class B:
age: int
#...
CLASSES = [A, B] #... more classes in list
Now I define a function that instantiate any one of the following class
def func(resource: Union[*CLASSES], value: Union[str, int]):
return resource(value)
But type-hinting is not valid here. How to do type hinting from List?