Skip to content

Commit

Permalink
base: mkarg: Fix typing.Unions to select first type
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed May 23, 2022
1 parent 14d44b4 commit 98f0234
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dffml/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def mkarg(field):
if hasattr(arg["type"], "load"):
# TODO (python3.8) Use Protocol
arg["type"] = arg["type"].load
elif get_origin(field.type) in (list, tuple):
elif get_origin(field.type) in (list, tuple, Union):
arg["type"] = get_args(field.type)[0]
arg["nargs"] = "+"
if get_origin(field.type) in (list, tuple):
arg["nargs"] = "+"
if "description" in field.metadata:
arg["help"] = field.metadata["description"]
if field.metadata.get("action"):
Expand Down

0 comments on commit 98f0234

Please sign in to comment.