Skip to content

Commit 223e7a9

Browse files
committed
ref: Use explicit MYPY constant for readability
1 parent cd2206f commit 223e7a9

33 files changed

+68
-34
lines changed

sentry_sdk/_compat.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22

3-
if False:
3+
MYPY = False
4+
if MYPY:
45
from typing import Optional
56
from typing import Tuple
67
from typing import Any

sentry_sdk/api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from sentry_sdk.scope import Scope
66

77

8-
if False:
8+
MYPY = False
9+
if MYPY:
910
from typing import Any
1011
from typing import Optional
1112
from typing import overload

sentry_sdk/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from sentry_sdk.integrations import setup_integrations
1818
from sentry_sdk.utils import ContextVar
1919

20-
if False:
20+
MYPY = False
21+
if MYPY:
2122
from typing import Any
2223
from typing import Callable
2324
from typing import Dict

sentry_sdk/consts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import socket
22

3-
if False:
3+
MYPY = False
4+
if MYPY:
45
from mypy_extensions import TypedDict
56
from typing import Optional
67
from typing import Callable

sentry_sdk/hub.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
)
1717

1818

19-
if False:
19+
MYPY = False
20+
if MYPY:
2021
from contextlib import ContextManager
2122
from sys import _OptExcInfo
2223

@@ -174,7 +175,8 @@ class Hub(with_metaclass(HubMeta)): # type: ignore
174175
_stack = None # type: List[Tuple[Optional[Client], Scope]]
175176

176177
# Mypy doesn't pick up on the metaclass.
177-
if False:
178+
MYPY = False
179+
if MYPY:
178180
current = None # type: Hub
179181
main = None # type: Hub
180182

sentry_sdk/integrations/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from sentry_sdk._compat import iteritems
77
from sentry_sdk.utils import logger
88

9-
if False:
9+
MYPY = False
10+
if MYPY:
1011
from typing import Iterator
1112
from typing import Dict
1213
from typing import List

sentry_sdk/integrations/_wsgi_common.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from sentry_sdk.utils import AnnotatedValue
55
from sentry_sdk._compat import text_type, iteritems
66

7-
if False:
7+
MYPY = False
8+
if MYPY:
89
from typing import Any
910
from typing import Dict
1011
from typing import Optional

sentry_sdk/integrations/aiohttp.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import asyncio
1616
from aiohttp.web import Application, HTTPException # type: ignore
1717

18-
if False:
18+
MYPY = False
19+
if MYPY:
1920
from aiohttp.web_request import Request # type: ignore
2021
from typing import Any
2122
from typing import Dict

sentry_sdk/integrations/argv.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from sentry_sdk.integrations import Integration
77
from sentry_sdk.scope import add_global_event_processor
88

9-
if False:
9+
MYPY = False
10+
if MYPY:
1011
from typing import Optional
1112

1213
from sentry_sdk.utils import Event, Hint

sentry_sdk/integrations/atexit.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from sentry_sdk.utils import logger
99
from sentry_sdk.integrations import Integration
1010

11-
if False:
11+
MYPY = False
12+
if MYPY:
1213

1314
from typing import Any
1415
from typing import Optional

sentry_sdk/integrations/aws_lambda.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from sentry_sdk.integrations import Integration
1212
from sentry_sdk.integrations._wsgi_common import _filter_headers
1313

14-
if False:
14+
MYPY = False
15+
if MYPY:
1516
from typing import Any
1617

1718

sentry_sdk/integrations/bottle.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
1111
from sentry_sdk.integrations._wsgi_common import RequestExtractor
1212

13-
if False:
13+
MYPY = False
14+
if MYPY:
1415

1516
from sentry_sdk.integrations.wsgi import _ScopedResponse
1617
from typing import Any

sentry_sdk/integrations/dedupe.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from sentry_sdk.integrations import Integration
44
from sentry_sdk.scope import add_global_event_processor
55

6-
if False:
6+
MYPY = False
7+
if MYPY:
78
from typing import Optional
89

910
from sentry_sdk.utils import Event, Hint

sentry_sdk/integrations/django/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from django import VERSION as DJANGO_VERSION # type: ignore
99
from django.core import signals # type: ignore
1010

11-
if False:
11+
MYPY = False
12+
if MYPY:
1213
from typing import Any
1314
from typing import Callable
1415
from typing import Dict

sentry_sdk/integrations/django/templates.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.template import TemplateSyntaxError # type: ignore
22

3-
if False:
3+
MYPY = False
4+
if MYPY:
45
from typing import Any
56
from typing import Dict
67
from typing import Optional

sentry_sdk/integrations/django/transactions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import re
99

10-
if False:
10+
MYPY = False
11+
if MYPY:
1112
from django.urls.resolvers import URLResolver # type: ignore
1213
from typing import Dict
1314
from typing import List

sentry_sdk/integrations/excepthook.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from sentry_sdk.utils import capture_internal_exceptions, event_from_exception
55
from sentry_sdk.integrations import Integration
66

7-
if False:
7+
MYPY = False
8+
if MYPY:
89
from typing import Callable
910
from typing import Any
1011

sentry_sdk/integrations/falcon.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
99
from sentry_sdk.utils import capture_internal_exceptions, event_from_exception
1010

11-
if False:
11+
MYPY = False
12+
if MYPY:
1213
from typing import Any
1314
from typing import Callable
1415
from typing import Dict

sentry_sdk/integrations/flask.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
99
from sentry_sdk.integrations._wsgi_common import RequestExtractor
1010

11-
if False:
11+
MYPY = False
12+
if MYPY:
1213

1314
from sentry_sdk.integrations.wsgi import _ScopedResponse
1415
from typing import Any

sentry_sdk/integrations/gnu_backtrace.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from sentry_sdk.scope import add_global_event_processor
66
from sentry_sdk.utils import capture_internal_exceptions
77

8-
if False:
8+
MYPY = False
9+
if MYPY:
910
from typing import Any
1011
from typing import Dict
1112

sentry_sdk/integrations/logging.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from sentry_sdk.integrations import Integration
1414
from sentry_sdk._compat import iteritems
1515

16-
if False:
16+
MYPY = False
17+
if MYPY:
1718
from logging import LogRecord
1819
from typing import Any
1920
from typing import Dict

sentry_sdk/integrations/modules.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from sentry_sdk.integrations import Integration
55
from sentry_sdk.scope import add_global_event_processor
66

7-
if False:
7+
MYPY = False
8+
if MYPY:
89
from typing import Any
910
from typing import Dict
1011
from typing import Tuple

sentry_sdk/integrations/pyramid.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from sentry_sdk.integrations._wsgi_common import RequestExtractor
1616
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
1717

18-
if False:
18+
MYPY = False
19+
if MYPY:
1920
from pyramid.response import Response # type: ignore
2021
from typing import Any
2122
from sentry_sdk.integrations.wsgi import _ScopedResponse

sentry_sdk/integrations/rq.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from rq.timeouts import JobTimeoutException # type: ignore
1010
from rq.worker import Worker # type: ignore
1111

12-
if False:
12+
MYPY = False
13+
if MYPY:
1314
from typing import Any
1415
from typing import Dict
1516
from typing import Callable

sentry_sdk/integrations/sanic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from sanic.router import Router # type: ignore
1919
from sanic.handlers import ErrorHandler # type: ignore
2020

21-
if False:
21+
MYPY = False
22+
if MYPY:
2223
from typing import Any
2324
from typing import Callable
2425
from typing import Optional

sentry_sdk/integrations/threading.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from sentry_sdk.utils import event_from_exception
1010
from sentry_sdk.integrations import Integration
1111

12-
if False:
12+
MYPY = False
13+
if MYPY:
1314
from typing import Any
1415

1516

sentry_sdk/integrations/tornado.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from tornado.web import RequestHandler, HTTPError # type: ignore
2121
from tornado.gen import coroutine # type: ignore
2222

23-
if False:
23+
MYPY = False
24+
if MYPY:
2425
from typing import Any
2526
from typing import List
2627
from typing import Optional

sentry_sdk/integrations/wsgi.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from sentry_sdk.tracing import SpanContext
77
from sentry_sdk.integrations._wsgi_common import _filter_headers
88

9-
if False:
9+
MYPY = False
10+
if MYPY:
1011
from typing import Callable
1112
from typing import Dict
1213
from typing import List

sentry_sdk/scope.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
from sentry_sdk.utils import logger, capture_internal_exceptions
77

8-
if False:
8+
MYPY = False
9+
if MYPY:
910
from typing import Any
1011
from typing import Dict
1112
from typing import Optional

sentry_sdk/serializer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
from sentry_sdk._compat import text_type, PY2, string_types, number_types, iteritems
1212

13-
if False:
13+
MYPY = False
14+
if MYPY:
1415
from typing import Any
1516
from typing import Dict
1617
from typing import List

sentry_sdk/transport.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from sentry_sdk.utils import Dsn, logger, capture_internal_exceptions
1313
from sentry_sdk.worker import BackgroundWorker
1414

15-
if False:
15+
MYPY = False
16+
if MYPY:
1617
from sentry_sdk.consts import ClientOptions
1718
from typing import Type
1819
from typing import Any

sentry_sdk/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from sentry_sdk._compat import urlparse, text_type, implements_str, int_types, PY2
1010

11-
if False:
11+
MYPY = False
12+
if MYPY:
1213
from typing import Any
1314
from typing import Callable
1415
from typing import Dict

sentry_sdk/worker.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from sentry_sdk._compat import queue, check_thread_support
66
from sentry_sdk.utils import logger
77

8-
if False:
8+
MYPY = False
9+
if MYPY:
910
from queue import Queue
1011
from typing import Any
1112
from typing import Optional

0 commit comments

Comments
 (0)