File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -375,17 +375,21 @@ def _strip_none_type(input_type):
375
375
if input_type is type (None ):
376
376
raise TypeError ("Option type cannot be only NoneType" )
377
377
378
- if isinstance (input_type , (types .UnionType , tuple )):
379
- args = (
380
- get_args (input_type )
381
- if isinstance (input_type , types .UnionType )
382
- else input_type
383
- )
378
+ args = ()
379
+ if isinstance (input_type , types .UnionType ):
380
+ args = get_args (input_type )
381
+ elif getattr (input_type , "__origin__" , None ) is Union :
382
+ args = get_args (input_type )
383
+ elif isinstance (input_type , tuple ):
384
+ args = input_type
385
+
386
+ if args :
384
387
filtered = tuple (t for t in args if t is not type (None ))
385
388
if not filtered :
386
389
raise TypeError ("Option type cannot be only NoneType" )
387
390
if len (filtered ) == 1 :
388
391
return filtered [0 ]
392
+
389
393
return filtered
390
394
391
395
return input_type
You can’t perform that action at this time.
0 commit comments