Open neighthan opened 4 years ago
While we're at it, we might as well just put the logic for the inner types into a little function as well. I think it might look clearer then, though, to have it linear instead of using a loop:
anno, kwargs = strip_optional(anno, kwargs)
anno, kwargs = strip_sequence(anno, kwargs)
anno, kwargs = inner_logic(anno, kwargs) # make a real name for this
Take a look at https://docs.python.org/3/whatsnew/3.8.html#typing; the new typing.get_origin
and typing.get_args
may be helpful to use.
When we're handling things like
Optional
(Union[T, None]
) orList
we essentially strip off one typing layer, possibly storing some information about it, and then proceed to get the parser arguments from the inner types. It would be nicer to wrap this logic into separate functions so we could do something like