8000 Resolve issue#52 (#53) · nirum-lang/nirum-python@c68554b · GitHub
[go: up one dir, main page]

Skip to content

Commit c68554b

Browse files
authored
Resolve issue#52 (#53)
* Change compat condition of is_union_type * Remove unnecessary condition * 0.3.5
1 parent 6e45a11 commit c68554b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

nirum/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
~~~~~~~~~~~~~~~
33
44
"""
5-
__version_info__ = 0, 3, 4
5+
__version_info__ = 0, 3, 5
66
__version__ = '.'.join(str(v) for v in __version_info__)

nirum/_compat.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,22 @@ def dst(self, dt):
2525
utc = UTC()
2626

2727

28-
if hasattr(typing, 'UnionMeta'):
28+
if hasattr(typing, '_Union'):
2929
def is_union_type(type_):
30-
return isinstance(type_, typing.UnionMeta) or \
31-
isinstance(type(type_), typing.UnionMeta)
30+
return isinstance(type_, typing._Union)
3231

3332
def get_union_types(type_):
3433
if is_union_type(type_):
35-
return type_.__union_params__ \
36-
if hasattr(type_, '__union_params__') \
37-
else type_.__args__
34+
return type_.__args__
3835
else:
3936
def is_union_type(type_):
40-
return isinstance(type_, typing._Union)
37+
return isinstance(type_, typing.UnionMeta)
4138

4239
def get_union_types(type_):
4340
if is_union_type(type_):
44-
return type_.__args__
41+
return type_.__union_params__ \
42+
if hasattr(type_, '__union_params__') \
43+
else type_.__args__
4544

4645

4746
def get_abstract_param_types(type_):

0 commit comments

Comments
 (0)
0