-
Notifications
You must be signed in to change notification settings - Fork 436
Closed
Labels
typingStatic typing definition related issues (mypy, pyright, etc.)Static typing definition related issues (mypy, pyright, etc.)v3Features that will be included in Powertools v3.Features that will be included in Powertools v3.
Milestone
Description
Static type checker used
pyright/pylance
AWS Lambda function runtime
3.12
Powertools for AWS Lambda (Python) version
latest
Static type checker info
Expression of type "Dict[str, Any] | None" cannot be assigned to declared type "dict[str, list[str]]"
Type "Dict[str, Any] | None" cannot be assigned to type "dict[str, list[str]]"
"None" is incompatible with "dict[str, list[str]]"
Code snippet
import json
from aws_lambda_powertools.event_handler.router import ALBRouter
router = ALBRouter()
@router.get("/")
def get_headers() -> str:
headers: dict[str, list[str]] = router.current_event.resolved_headers_field
return json.dumps(headers)
### Possible Solution
Remove `Optional`
```diff
- def resolved_headers_field(self) -> Optional[Dict[str, Any]]:
+ def resolved_headers_field(self) -> Dict[str, Any]:
Metadata
Metadata
Assignees
Labels
typingStatic typing definition related issues (mypy, pyright, etc.)Static typing definition related issues (mypy, pyright, etc.)v3Features that will be included in Powertools v3.Features that will be included in Powertools v3.
Type
Projects
Status
Shipped