Input module: native support for on-demand validation?

Consider this code:

from typing import Tuple
t = Tuple[str, int]
x = ('a', 1)
y = ('b', 'c')
assert f(x, t)
assert not f(y, t)

      

Is there a built-in function that checks the type of a request for a type typing

that behaves equivalently to the function f

above? I researched the documentation but didn't find what seems like an obvious function, so maybe I just missed it?


Further verification:

Tuple[str, int].__tuple_params__

- (str, int)


List[int].__args__

-(int,)


Dict[str, int].__args__

(str, int)

+3


source to share





All Articles