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):
375375 if input_type is type (None ):
376376 raise TypeError ("Option type cannot be only NoneType" )
377377
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 :
384387 filtered = tuple (t for t in args if t is not type (None ))
385388 if not filtered :
386389 raise TypeError ("Option type cannot be only NoneType" )
387390 if len (filtered ) == 1 :
388391 return filtered [0 ]
392+
389393 return filtered
390394
391395 return input_type
You can’t perform that action at this time.
0 commit comments