MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / get_args

Function get_args

tools/python-3.11.9-amd64/Lib/typing.py:2473–2496  ·  view source on GitHub ↗

Get type arguments with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. Examples:: >>> T = TypeVar('T') >>> assert get_args(Dict[str, int]) == (str, int) >>> assert get_args(int) == () >>> ass

(tp)

Source from the content-addressed store, hash-verified

2471
2472
2473def get_args(tp):
2474 """Get type arguments with all substitutions performed.
2475
2476 For unions, basic simplifications used by Union constructor are performed.
2477
2478 Examples::
2479
2480 >>> T = TypeVar('T')
2481 >>> assert get_args(Dict[str, int]) == (str, int)
2482 >>> assert get_args(int) == ()
2483 >>> assert get_args(Union[int, Union[T, int], str][int]) == (int, str)
2484 >>> assert get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
2485 >>> assert get_args(Callable[[], T][int]) == ([], int)
2486 """
2487 if isinstance(tp, _AnnotatedAlias):
2488 return (tp.__origin__,) + tp.__metadata__
2489 if isinstance(tp, (_GenericAlias, GenericAlias)):
2490 res = tp.__args__
2491 if _should_unflatten_callable_args(tp, res):
2492 res = (list(res[:-1]), res[-1])
2493 return res
2494 if isinstance(tp, types.UnionType):
2495 return tp.__args__
2496 return ()
2497
2498
2499def is_typeddict(tp):

Callers 3

_is_valid_dispatch_typeFunction · 0.90
registerFunction · 0.90
__new__Method · 0.70

Calls 2

listFunction · 0.85

Tested by

no test coverage detected