From a25e324c2ce55326c825ed93f3135bba21f3b3a5 Mon Sep 17 00:00:00 2001 From: Glen Date: Wed, 9 Sep 2020 11:06:35 -0500 Subject: [PATCH] fix-linter --- mypy.ini | 2 ++ sentry_sdk/integrations/chalice.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 06f02ac59c..789f89ab4e 100644 --- a/mypy.ini +++ b/mypy.ini @@ -54,3 +54,5 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-pure_eval.*] ignore_missing_imports = True +[mypy-chalice.*] +ignore_missing_imports = True diff --git a/sentry_sdk/integrations/chalice.py b/sentry_sdk/integrations/chalice.py index c1c4c31f57..96828aaa93 100644 --- a/sentry_sdk/integrations/chalice.py +++ b/sentry_sdk/integrations/chalice.py @@ -12,12 +12,21 @@ capture_internal_exceptions, event_from_exception, ) +from sentry_sdk._types import MYPY + +if MYPY: + from typing import Any + from typing import TypeVar + from typing import Callable + + F = TypeVar("F", bound=Callable[..., Any]) class EventSourceHandler(ChaliceEventSourceHandler): def __call__(self, event, context): + # type: (Any, Any) -> Any hub = Hub.current - client = hub.client + client = hub.client # type: Any with hub.push_scope() as scope: with capture_internal_exceptions(): @@ -41,10 +50,12 @@ def __call__(self, event, context): def _get_view_function_response(app, view_function, function_args): + # type: (Any, F, Any) -> F @wraps(view_function) def wrapped_view_function(**function_args): + # type: (**Any) -> Any hub = Hub.current - client = hub.client + client = hub.client # type: Any with hub.push_scope() as scope: with capture_internal_exceptions(): configured_time = app.lambda_context.get_remaining_time_in_millis() @@ -71,7 +82,7 @@ def wrapped_view_function(**function_args): hub.flush() raise - return wrapped_view_function + return wrapped_view_function # type: ignore class ChaliceIntegration(Integration): @@ -79,9 +90,11 @@ class ChaliceIntegration(Integration): @staticmethod def setup_once(): + # type: () -> None old_get_view_function_response = Chalice._get_view_function_response def sentry_event_response(app, view_function, function_args): + # type: (Any, F, **Any) -> Any wrapped_view_function = _get_view_function_response( app, view_function, function_args )