Skip to content

fix(middleware_factory): ret type annotation for handler dec #1066

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

Merged
merged 3 commits into from
Apr 8, 2022
Merged
Changes from 2 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
7 changes: 4 additions & 3 deletions aws_lambda_powertools/middleware_factory/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import inspect
import logging
import os
from typing import Callable, Optional
from typing import Any, Callable, Optional

from ..shared import constants
from ..shared.functions import resolve_truthy_env_var_choice
Expand All @@ -12,7 +12,8 @@
logger = logging.getLogger(__name__)


def lambda_handler_decorator(decorator: Optional[Callable] = None, trace_execution: Optional[bool] = None):
# giving this an accurate return type is hard
def lambda_handler_decorator(decorator: Optional[Callable] = None, trace_execution: Optional[bool] = None) -> Callable:
"""Decorator factory for decorating Lambda handlers.

You can use lambda_handler_decorator to create your own middlewares,
Expand Down Expand Up @@ -110,7 +111,7 @@ def lambda_handler(event, context):
)

@functools.wraps(decorator)
def final_decorator(func: Optional[Callable] = None, **kwargs):
def final_decorator(func: Optional[Callable] = None, **kwargs: Any):
# If called with kwargs return new func with kwargs
if func is None:
return functools.partial(final_decorator, **kwargs)
Expand Down