File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change 16
16
Union ,
17
17
cast ,
18
18
overload ,
19
- Tuple ,
20
19
)
21
20
22
21
import numpy as np
@@ -103,17 +102,18 @@ def _setter(self, value):
103
102
104
103
# # The global scope and qualname need to refer to this class a unique name.
105
104
# # Otherwise, creating another _DocArrayTyped will overwrite this one.
106
- change_cls_name (
107
- _DocArrayTyped , f'{ cls .__name__ } ' , globals ()
108
- )
109
-
110
- if sys .version_info < (3 , 12 ):
111
- cls .__typed_da__ [cls ][item ] = Generic .__class_getitem__ .__func__ (_DocArrayTyped , item ) # type: ignore
112
- # this do nothing that checking that item is valid type var or str
113
- # Keep the approach in #1147 to be compatible with lower versions of Python.
105
+ if not is_pydantic_v2 :
106
+ change_cls_name (_DocArrayTyped , f'{ cls .__name__ } [{ item } ]' , globals ())
107
+ cls .__typed_da__ [cls ][item ] = _DocArrayTyped
114
108
else :
115
- cls .__typed_da__ [cls ][item ] = GenericAlias (_DocArrayTyped , item ) # type: ignore
116
-
109
+ if sys .version_info < (3 , 12 ):
110
+ cls .__typed_da__ [cls ][item ] = Generic .__class_getitem__ .__func__ (
111
+ _DocArrayTyped , item
112
+ ) # type: ignore
113
+ # this do nothing that checking that item is valid type var or str
114
+ # Keep the approach in #1147 to be compatible with lower versions of Python.
115
+ else :
116
+ cls .__typed_da__ [cls ][item ] = GenericAlias (_DocArrayTyped , item ) # type: ignore
117
117
return cls .__typed_da__ [cls ][item ]
118
118
119
119
@overload
You can’t perform that action at this time.
0 commit comments