-
Notifications
You must be signed in to change notification settings - Fork 471
Feature request: Return empty Dict or List in Event Source Data Classes instead of None #2605
Copy link
Copy link
Closed
Labels
breaking-changeBreaking changeBreaking changefeature-requestfeature requestfeature requesthelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handsneed-customer-feedbackRequires more customers feedback before making or revisiting a decisionRequires more customers feedback before making or revisiting a decisionneed-rfcrevisitMaintainer to provide update or revisit prioritization in the next cycleMaintainer to provide update or revisit prioritization in the next cyclev3Features that will be included in Powertools v3.Features that will be included in Powertools v3.
Milestone
Metadata
Metadata
Assignees
Labels
breaking-changeBreaking changeBreaking changefeature-requestfeature requestfeature requesthelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handsneed-customer-feedbackRequires more customers feedback before making or revisiting a decisionRequires more customers feedback before making or revisiting a decisionneed-rfcrevisitMaintainer to provide update or revisit prioritization in the next cycleMaintainer to provide update or revisit prioritization in the next cyclev3Features that will be included in Powertools v3.Features that will be included in Powertools v3.
Type
Projects
Status
Shipped
Use case
Arguably, it might be easier for users if an empty Dict is returned instead of
Nonefor path_parameters in APIGatewayProxyEventV2, for example.Instead of:
it would become:
Ultimately this approach could be followed for any return value that is either an Optional[Dict] or an Optional[List], returning an empty Dict or List instead of
Nonein all cases:def claims(self) -> Dict[str, Any]def scopes(self) -> List[str]def multi_value_query_string_parameters(self) -> Dict[str, List[str]]def path_parameters(self) -> Dict[str, str]def stage_variables(self) -> Dict[str, str]def cognito_amr(self) -> List[str]def jwt_claim(self) -> Dict[str, Any]def jwt_scopes(self) -> List[str]def get_lambda(self) -> Dict[str, Any]def cookies(self) -> List[str]def path_parameters(self) -> Dict[str, str]def stage_variables(self) -> Dict[str, str]and so on...
The bottom line is: Does it matter for users to differentiate between
Noneand an empty Dict or List for any Event Source Data Classe property? If it does for a particular one, it an exception to a rule or the rule?This change would be backwards compatible with the previous code.
This approach was already implemented in only one place so far, as far as I could check:
def headers(self) -> Dict[str, str]Solution/User Experience
Solution can be the same as for the headers in the BaseProxyEvent:
powertools-lambda-python/aws_lambda_powertools/utilities/data_classes/common.py
Lines 98 to 100 in 1905e4c
Alternative solutions
No response
Acknowledgment