Skip to content

Commit

Permalink
Python 3.6 fix related to handling bare Union (#4638)
Browse files Browse the repository at this point in the history
In Python 3.6 bare Union has `__args__` but it's None which causes
problems. Our handy `has_args` utility handles such special cases.
  • Loading branch information
pekkaklarck committed Feb 28, 2023
1 parent 2b6c764 commit 9ecdfa3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/robot/running/arguments/typeconverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

from robot.conf import Languages
from robot.libraries.DateTime import convert_date, convert_time
from robot.utils import (eq, get_error_message, is_string, is_union, plural_or_not as s,
safe_str, seq2str, type_name, type_repr, typeddict_types)
from robot.utils import (eq, get_error_message, has_args, is_string, is_union,
plural_or_not as s, safe_str, seq2str, type_name, type_repr,
typeddict_types)


NoneType = type(None)
Expand Down Expand Up @@ -666,7 +667,9 @@ def _get_types(self, union):
return ()
if isinstance(union, tuple):
return union
return getattr(union, '__args__', ())
if has_args(union):
return union.__args__
return ()

@property
def type_name(self):
Expand Down

0 comments on commit 9ecdfa3

Please sign in to comment.