generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 456
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Use case
By default json.dumps is initialized with ensure_ascii: bool = True which escapes all non-ASCII output.
To overcome this, one has to recreate the internal serializer from scratch and pass it as a custom serializer:
serializer = functools.partial(json.dumps, separators=(",", ":"), cls=json_encoder.Encoder, ensure_ascii=False)
app = APIGatewayHttpResolver(serializer=serializer)This hardcodes many of the library design choices on the app side.
Solution/User Experience
Allow passing additional parameters to the serializer initialization:
app = APIGatewayHttpResolver(serializer_kwargs={'ensure_ascii': False})def __init__(self, serializer_kwargs: dict):
# Allow for a custom serializer or a concise json serialization
self._serializer = serializer or partial(json.dumps, separators=(",", ":"), cls=Encoder, **serializer_kwargs)Proposed solution is similar to the LangChain library design:
https://api.python.langchain.com/en/latest/chains/langchain.chains.llm.LLMChain.html#langchain.chains.llm.LLMChain.llm_kwargs
Alternative solutions
Hardcode serializer args:
self._serializer = serializer or partial(json.dumps, separators=(",", ":"), cls=Encoder, ensure_ascii=False)Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Closed