Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localstack-core/localstack/aws/scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def generate_service_api(output, service: ServiceModel, doc=True):
type_name = to_valid_python_name(m_shape.name)
if m == streaming_payload_member:
type_name = f"IO[{type_name}]"
parameters[xform_name(m)] = f"{type_name} = None"
parameters[xform_name(m)] = f"{type_name} | None = None"

if any(map(is_bad_param_name, parameters.keys())):
# if we cannot render the parameter name, don't expand the parameters in the handler
Expand Down
10 changes: 7 additions & 3 deletions localstack-core/localstack/testing/aws/asf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pkgutil
import re
from types import FunctionType, ModuleType, NoneType, UnionType
from typing import Optional, Pattern, get_args
from typing import Optional, Pattern, Union, get_args, get_origin


def _import_submodules(
Expand Down Expand Up @@ -160,8 +160,12 @@ def check_provider_signature(sub_class: type, base_class: type, method_name: str


def _remove_optional(_type: type) -> list[type]:
if type(_type) == UnionType:
if get_origin(_type) in [Union, UnionType]:
union_types = list(get_args(_type))
union_types.remove(NoneType)
try:
union_types.remove(NoneType)
except ValueError:
# Union of some other kind, like 'str | int'
pass
return union_types
return [_type]
Loading