Refactor extract_union_types_from_generic_alias function to exclude specific types
This commit is contained in:
parent
1cd651e300
commit
0788951ba4
1 changed files with 7 additions and 1 deletions
|
|
@ -36,5 +36,11 @@ def extract_union_types_from_generic_alias(return_type: GenericAlias) -> list:
|
|||
Extracts the inner type from a type hint that is a Union.
|
||||
"""
|
||||
if isinstance(return_type, list):
|
||||
return [_inner_arg for _type in return_type for _inner_arg in _type.__args__]
|
||||
return [
|
||||
_inner_arg
|
||||
for _type in return_type
|
||||
for _inner_arg in _type.__args__
|
||||
if _inner_arg not in set((Any, type(None), type(Any)))
|
||||
]
|
||||
|
||||
return list(return_type.__args__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue