File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
- import inspect
2
1
import re
3
- import types
4
2
import typing
5
3
import warnings
6
4
from collections import deque
12
10
13
11
from ..utils import exceptions as exc
14
12
from ..utils .compat import (ForwardRef , Literal , evaluate_forward_ref ,
15
- get_args , get_origin )
13
+ get_args , get_origin , UnionType )
16
14
from ..utils .datastructures import unprovided
17
15
from ..utils .functional import multi , pop
18
16
from ..utils .transform import TypeTransformer
@@ -1308,7 +1306,7 @@ def annotate(
1308
1306
# return type_
1309
1307
1310
1308
name = cls .__name__
1311
- if type_ == Union or type_ == types . UnionType :
1309
+ if type_ == Union or type_ == UnionType :
1312
1310
# in Python >= 3.10, native logic operator like int | str will be a UnionType
1313
1311
type_ = LogicalType .any_of (* args )
1314
1312
# clear the args for union
Original file line number Diff line number Diff line change 11
11
except ImportError :
12
12
from typing_extensions import Literal
13
13
14
+ try :
15
+ from types import UnionType
16
+ except ImportError :
17
+ UnionType = Union
18
+
14
19
try :
15
20
from typing import Final
16
21
except ImportError :
27
32
"get_args" ,
28
33
'Literal' ,
29
34
'Final' ,
35
+ 'UnionType' ,
30
36
"ForwardRef" ,
31
37
"Annotated" ,
32
38
"is_final" ,
You can’t perform that action at this time.
0 commit comments