From 70d6d66318ac36c764b336f4fa448a89f32f8a0a Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 27 Jul 2019 21:17:36 -0400 Subject: [PATCH 1/3] fix: types for logging integration args The sdk supports disabling the LoggingIntegration by passing `None` as arguments; however, the current types require ints. This behavior is noted in the docs: https://docs.sentry.io/platforms/python/logging/#options ``` sentry_sdk.init(integrations=[LoggingIntegration(level=None, event_level=None)]) ``` --- sentry_sdk/integrations/logging.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index 647067fd09..512c3dada5 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -19,6 +19,7 @@ from logging import LogRecord from typing import Any from typing import Dict + from typing import Optional DEFAULT_LEVEL = logging.INFO DEFAULT_EVENT_LEVEL = logging.ERROR @@ -40,7 +41,7 @@ class LoggingIntegration(Integration): identifier = "logging" def __init__(self, level=DEFAULT_LEVEL, event_level=DEFAULT_EVENT_LEVEL): - # type: (int, int) -> None + # type: (Optional[int], Optional[int]) -> None self._handler = None self._breadcrumb_handler = None From fc898bba87fe412159a4aa3e3cebfc88431aac3b Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 27 Jul 2019 22:27:02 -0400 Subject: [PATCH 2/3] fix: type for integration's arg ```python integrations = [ LoggingIntegration(level=None, event_level=None) # type: ignore ] sentry_sdk.init(integrations=integrations) ``` here are the type errors from mypy ``` Argument "integrations" to "init" has incompatible type "List[LoggingIntegration]"; expected "List[Integration]" "List" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance Consider using "Sequence" instead, which is covariant ``` --- sentry_sdk/consts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index ca71142fde..1e63e3b586 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -27,7 +27,7 @@ def __init__( environment=None, # type: Optional[str] server_name=None, # type: Optional[str] shutdown_timeout=2, # type: int - integrations=[], # type: List[Integration] + integrations=[], # type: Sequence[Integration] in_app_include=[], # type: List[str] in_app_exclude=[], # type: List[str] default_integrations=True, # type: bool From e0b0fa7aa96a39151fb31edcc083653e0e220b78 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 27 Jul 2019 22:29:46 -0400 Subject: [PATCH 3/3] add missing import --- sentry_sdk/consts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index 1e63e3b586..6470e9e462 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -8,6 +8,7 @@ from typing import Type from typing import Dict from typing import Any + from typing import Sequence from sentry_sdk.transport import Transport from sentry_sdk.integrations import Integration