Python typing: return type with generics like Clazz[T] as in Java Clazz<T>
问题 So I am aware of pythons typing.Optional. But I wrote my own crude PyOptional (https://github.com/felixhertrampf/PyOptional/blob/master/PyOptional.py) and would like to combine Optional[T] with my PyOptional to PyOptional[T]. I am currently using Python 3.7 and tried extending typing.Optional. Some of my PyOptional class PyOptional: T: TypeVar = TypeVar("T") def __init__(self, obj: T): self.value: Any = obj def get(self) -> Optional[T]: return self.value def or_else(self, default) -> T: