I have the following setup: This works great, but I’ve tied my Callable to str and int, and I would want something even more generic like being able to define func as something like: where A and B can be whatever, so I can define and send a func like (a: Type[str]) -> Type[int]:… or (a: Type[float]) -> Type[str]:… or
Tag: generics
What’s the correct way to check if an object is a typing.Generic?
I’m trying to write code that validates type hints, and in order to do so I have to find out what kind of object the annotation is. For example, consider this snippet that’s supposed to tell the user what kind of value is expected: This should print “value type should be one of (int, str)”, but instead it throws an
Correct way use type hints / generics to describe arguments of type class (“type”)
This appears to be similar to Type Hinting: Argument Of Type Class, however, the accepted answer there does not actually answer my question, so perhaps the question was expressed incorrectly (?) I have a serialization/deserialization framework that would benefit greatly from [IDE-supported] type hinting. The API looks something like this: The serialization method is fine, but deserialize type hinting is