Skip to content

Commit

Permalink
refactor(middleware_factory): add from __future__ import annotations
Browse files Browse the repository at this point in the history
and update code according to ruff rules TCH, UP006, UP007, UP037 and
FA100.
  • Loading branch information
ericbn committed Aug 13, 2024
1 parent 2d59b7a commit 9db63ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions aws_lambda_powertools/middleware_factory/factory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

import functools
import inspect
import logging
import os
from typing import Any, Callable, Optional
from typing import Any, Callable

from ..shared import constants
from ..shared.functions import resolve_truthy_env_var_choice
Expand All @@ -13,7 +15,7 @@


# Maintenance: we can't yet provide an accurate return type without ParamSpec etc. see #1066
def lambda_handler_decorator(decorator: Optional[Callable] = None, trace_execution: Optional[bool] = None) -> Callable:
def lambda_handler_decorator(decorator: Callable | None = None, trace_execution: bool | None = None) -> Callable:
"""Decorator factory for decorating Lambda handlers.
You can use lambda_handler_decorator to create your own middlewares,
Expand Down Expand Up @@ -112,7 +114,7 @@ def lambda_handler(event, context):
)

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

0 comments on commit 9db63ef

Please sign in to comment.