I'm trying to use generic type hints in python, however I'm not sure if a behaviour I want is possible or not. I've done a lot of reading on the type hints documentation, but cannot find what I'm looking for.
I want to be able to specify class type arguments with default types if the type isn't defined. For instance, I would imagine the code would look something like this.
T = TypeVar('T') S = TypeVar('S') class Attribute(Generic[T, S=int]): ... class FooBar: a: Attribute[str, str] b: Attribute[str] So in this case type S would default to int if it is not specified in a type hint. I am also happy with a solution which uses metaprogramming to make this possible.