-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static typing: resolved_headers_field is not Optional #4147
Comments
Hi @Wurstnase I'm not sure I follow this one. One could argue that checking the implementation, the field is always present. But due to Hyrum's Law I would prefer to add this to our v3 branch (more on that earlier next week). @leandrodamascena I would appreciate your thoughts here too |
Yes! I agree with you @rubenfonseca that we should avoid doing this now and tag this issue/pr as eligible for Powertools V3. |
Hope that's ok with you @Wurstnase. I'll add this to our v3 queue. I promise v3 is not far ahead ;) |
@rubenfonseca @leandrodamascena def resolved_headers_field(self) -> Optional[Dict[str, Any]]:
headers: Dict[str, Any] = {}
if self.multi_value_headers:
headers = self.multi_value_headers
else:
headers = self.headers
return {key.lower(): value for key, value in headers.items()} As you can see, finally we return a dict at any time. It is impossible to return None. At least this could become an empty dict, but never None. |
Nico is correct,
That said, there's a few other places for its associated PR to be statically correct., Sending fixes today |
fixes pushed, tests suite ran successfully. Pending PR CI suite |
|
Everyone - appreciate the help and cautious in raising the bar for everyone's experience. Merged, ran e2e tests, and pushed additional fixes to complete the PR. Bottom line: |
Static type checker used
pyright/pylance
AWS Lambda function runtime
3.12
Powertools for AWS Lambda (Python) version
latest
Static type checker info
Code snippet
The text was updated successfully, but these errors were encountered: