File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,27 @@ def is_namedtuple(tp: Any, /) -> bool:
182
182
return lenient_issubclass (tp , tuple ) and hasattr (tp , '_fields' )
183
183
184
184
185
+ # TODO In 2.12, delete this function. It is currently defined only to not break
186
+ # pydantic-settings which relies on it:
187
+ _t_union = typing .Union
188
+ _te_union = typing_extensions .Union
189
+
190
+ _t_union = typing .Union
191
+ _te_union = typing_extensions .Union
192
+
193
+ if sys .version_info >= (3 , 10 ):
194
+
195
+ def origin_is_union (tp : Any , / ) -> bool :
196
+ """Return whether the provided argument is the `Union` special form or the `UnionType`."""
197
+ return tp is _t_union or tp is _te_union or tp is types .UnionType
198
+
199
+ else :
200
+
201
+ def origin_is_union (tp : Any , / ) -> bool :
202
+ """Return whether the provided argument is the `Union` special form."""
203
+ return tp is _t_union or tp is _te_union
204
+
205
+
185
206
def is_generic_alias (tp : Any , / ) -> bool :
186
207
return isinstance (tp , (types .GenericAlias , typing ._GenericAlias )) # pyright: ignore[reportAttributeAccessIssue]
187
208
You can’t perform that action at this time.
0 commit comments