You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we're handling things like Optional (Union[T, None]) or List 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
anno=param.annotationkwargs= {}
forpreprocess_funcin [strip_optional, strip_sequence]:
anno, kwargs=preprocess_func(anno, kwargs)
# the rest of the logic for inner types
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
Activity
neighthan commentedon Jun 26, 2020
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:
neighthan commentedon Jan 25, 2021
Take a look at https://docs.python.org/3/whatsnew/3.8.html#typing; the new
typing.get_originandtyping.get_argsmay be helpful to use.