How to use a generic function defined in Python?
I have a class and a corresponding factory function that holds some state in a closure (event_bus
):
What’s the simplest way to annotate a function/method parameter to accept an overlapping Union of types?
In all my functions that allow an overlapping union of types, I already have special handling that checks all parameters to ensure that there are no types which don’t support operations with each other.
Generic[T] classmethod implicit type retrieval in Python 3.12
I would like to use the new Python 3.12 generic type signature syntax to know the type of an about-to-be-instantiated class within the classmethod of that class.