Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ You might find useful to run both the documentation website and the API referenc
| Category | Convention |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Docstring** | We use a slight variation of Numpy convention with markdown to help generate more readable API references. |
| **Style guide** | We use black as well as [Ruff](https://beta.ruff.rs/docs/) to enforce beyond good practices [PEP8](https://pep8.org/). We use type annotations and enforce static type checking at CI (mypy). |
| **Style guide** | We use black as well as [Ruff](https://docs.astral.sh/ruff/) to enforce beyond good practices [PEP8](https://pep8.org/). We use type annotations and enforce static type checking at CI (mypy). |
| **Core utilities** | Core utilities use a Class, always accept `service` as a constructor parameter, can work in isolation, and are also available in other languages implementation. |
| **Utilities** | Utilities are not as strict as core and focus on solving a developer experience problem while following the project [Tenets](https://docs.powertools.aws.dev/lambda/python/#tenets). |
| **Exceptions** | Specific exceptions live within utilities themselves and use `Error` suffix e.g. `MetricUnitError`. |
Expand Down
3 changes: 2 additions & 1 deletion aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from functools import partial
from http import HTTPStatus
from pathlib import Path
from typing import TYPE_CHECKING, Any, Generic, Literal, Match, Pattern, TypeVar, cast
from re import Match, Pattern
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar, cast

from typing_extensions import override

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import warnings
from typing import TYPE_CHECKING, Any

from aws_lambda_powertools.event_handler.events_appsync.exceptions import UnauthorizedException
from aws_lambda_powertools.event_handler.events_appsync.exceptions import (
UnauthorizedException,
)
from aws_lambda_powertools.event_handler.events_appsync.router import Router
from aws_lambda_powertools.utilities.data_classes.appsync_resolver_events_event import AppSyncResolverEventsEvent
from aws_lambda_powertools.utilities.data_classes.appsync_resolver_events_event import (
AppSyncResolverEventsEvent,
)
from aws_lambda_powertools.warnings import PowertoolsUserWarning

if TYPE_CHECKING:
Expand Down Expand Up @@ -321,7 +325,7 @@ async def _call_publish_event_async_resolver(
if isinstance(ret, Exception)
else {"id": e.get("id"), "payload": ret}
)
for e, ret in zip(self.current_event.events, results)
for e, ret in zip(self.current_event.events, results, strict=False)
],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Callable
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable

DEFAULT_ROUTE = "/default/*"

Expand Down
4 changes: 2 additions & 2 deletions aws_lambda_powertools/event_handler/exception_handling.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Mapping
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Callable, Mapping


class ExceptionHandlerManager:
Expand Down
4 changes: 3 additions & 1 deletion aws_lambda_powertools/event_handler/http_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import base64
import inspect
import warnings
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any
from urllib.parse import parse_qs

from aws_lambda_powertools.event_handler.api_gateway import (
Expand All @@ -18,6 +18,8 @@
from aws_lambda_powertools.utilities.data_classes.common import BaseProxyEvent

if TYPE_CHECKING:
from collections.abc import Callable

from aws_lambda_powertools.shared.cookies import Cookie


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Pattern
from typing import TYPE_CHECKING

from aws_lambda_powertools.event_handler.api_gateway import (
ApiGatewayResolver,
Expand All @@ -10,6 +10,7 @@
if TYPE_CHECKING:
from collections.abc import Callable
from http import HTTPStatus
from re import Pattern

from aws_lambda_powertools.event_handler import CORSConfig
from aws_lambda_powertools.utilities.data_classes import LambdaFunctionUrlEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses
import json
import logging
from typing import TYPE_CHECKING, Any, Callable, Mapping, MutableMapping, Sequence, cast
from typing import TYPE_CHECKING, Any, cast
from urllib.parse import parse_qs

from pydantic import BaseModel
Expand All @@ -27,6 +27,8 @@
from aws_lambda_powertools.event_handler.openapi.params import Param

if TYPE_CHECKING:
from collections.abc import Callable, Mapping, MutableMapping, Sequence

from pydantic.fields import FieldInfo

from aws_lambda_powertools.event_handler import Response
Expand Down
16 changes: 9 additions & 7 deletions aws_lambda_powertools/event_handler/openapi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
from collections.abc import Mapping, Sequence
from copy import copy
from dataclasses import dataclass, is_dataclass
from typing import TYPE_CHECKING, Any, Deque, FrozenSet, List, Set, Tuple, Union
from typing import (
TYPE_CHECKING,
Annotated,
Any,
Literal,
Union,
get_args,
get_origin,
)

from pydantic import BaseModel, TypeAdapter, ValidationError, create_model

Expand All @@ -16,7 +24,6 @@
from pydantic._internal._utils import lenient_issubclass
from pydantic.fields import FieldInfo as PydanticFieldInfo
from pydantic_core import PydanticUndefined, PydanticUndefinedType
from typing_extensions import Annotated, Literal, get_args, get_origin

from aws_lambda_powertools.event_handler.openapi.types import UnionType

Expand All @@ -34,15 +41,10 @@

sequence_annotation_to_type = {
Sequence: list,
List: list,
list: list,
Tuple: tuple,
tuple: tuple,
Set: set,
set: set,
FrozenSet: frozenset,
frozenset: frozenset,
Deque: deque,
deque: deque,
}

Expand Down
Loading