File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -372,12 +372,15 @@ def _strip_none_type(input_type):
372
372
if input_type is type (None ):
373
373
raise TypeError ("Option type cannot be only NoneType" )
374
374
375
- if isinstance (input_type , (types .UnionType , tuple )):
376
- args = (
377
- get_args (input_type )
378
- if isinstance (input_type , types .UnionType )
379
- else input_type
380
- )
375
+ args = ()
376
+ if isinstance (input_type , types .UnionType ):
377
+ args = get_args (input_type )
378
+ elif getattr (input_type , "__origin__" , None ) is Union :
379
+ args = get_args (input_type )
380
+ elif isinstance (input_type , tuple ):
381
+ args = input_type
382
+
383
+ if args :
381
384
filtered = tuple (t for t in args if t is not type (None ))
382
385
if not filtered :
383
386
raise TypeError ("Option type cannot be only NoneType" )
You can’t perform that action at this time.
0 commit comments