diff --git a/Makefile b/Makefile index 73667eb5f58..a430f61b0c6 100644 --- a/Makefile +++ b/Makefile @@ -90,3 +90,10 @@ changelog: mypy: poetry run mypy --pretty aws_lambda_powertools + +format-examples: + poetry run isort docs/examples + poetry run black docs/examples/*/*/*.py + +lint-examples: + poetry run python3 -m py_compile docs/examples/*/*/*.py diff --git a/docs/examples/utilities/typing/lambda_context.py b/docs/examples/utilities/typing/lambda_context.py new file mode 100644 index 00000000000..0ad59a19d79 --- /dev/null +++ b/docs/examples/utilities/typing/lambda_context.py @@ -0,0 +1,8 @@ +from typing import Any, Dict + +from aws_lambda_powertools.utilities.typing import LambdaContext + + +def handler(event: Dict[str, Any], context: LambdaContext) -> Dict[str, Any]: + # Insert business logic + return event diff --git a/docs/utilities/typing.md b/docs/utilities/typing.md index c1b4dbad32b..75587fef07b 100644 --- a/docs/utilities/typing.md +++ b/docs/utilities/typing.md @@ -11,11 +11,6 @@ This typing utility provides static typing classes that can be used to ease the The `LambdaContext` typing is typically used in the handler method for the Lambda function. -```python hl_lines="4" title="Annotating Lambda context type" -from typing import Any, Dict -from aws_lambda_powertools.utilities.typing import LambdaContext - -def handler(event: Dict[str, Any], context: LambdaContext) -> Dict[str, Any]: - # Insert business logic - return event +```python hl_lines="6" title="Annotating Lambda context type" +--8<-- "docs/examples/utilities/typing/lambda_context.py" ```