Skip to content

Commit

Permalink
fix(docs): Extract typing code examples
Browse files Browse the repository at this point in the history
Changes:
- Extract code example
- Run isort and black
- Update line highlight
- Add make task for formatting and linting

Related to:
- aws-powertools#1064
  • Loading branch information
michaelbrewer committed Apr 13, 2022
1 parent b577366 commit e2494ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions docs/examples/utilities/typing/lambda_context.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 2 additions & 7 deletions docs/utilities/typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

0 comments on commit e2494ee

Please sign in to comment.