1
유형을 사용하고 해당 유형의 요소를 재귀 적으로 생성하는 함수가 있습니다. 예를 들어, typing.NamedTuple
초 동안 나는이 수행 그러나입력에서 요소 유형 가져 오기.
def make_type(type_):
...
if issubclass(type_, typing.NamedTuple):
return type_(**{f: make_type(t) for f, t in type_._field_types.items()})
을, 나는 그들이 _field_types
의 동등한 것 같다하지 않는 한, typing.Tuple
의를 처리하는 방법을 모르겠어요. 예를 들어 Tuple[int, int]
이 있으면 (int, int)
으로 돌아가고 싶습니다.
Pair = typing.Tuple[int, int]
Pair.__args__ # (int, int)
내가이 단지 Tuple
타입 생성자에 전달 된 인수 목록입니다 가정 :