Skip to content

Commit e6a2c91

Browse files
authored
Fix mypy hinting of toplevel sentry_sdk module (getsentry#892)
Mypy does not support runtime-calculated __all__, so duplicate symbols from sentry_sdk.api.__all__ to top-level __init__.py. Tested with mypy 0.790.
1 parent 34f173f commit e6a2c91

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

sentry_sdk/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@
44
from sentry_sdk.client import Client
55

66
from sentry_sdk.api import * # noqa
7-
from sentry_sdk.api import __all__ as api_all
87

98
from sentry_sdk.consts import VERSION # noqa
109

11-
__all__ = api_all + [ # noqa
10+
__all__ = [ # noqa
1211
"Hub",
1312
"Scope",
1413
"Client",
1514
"Transport",
1615
"HttpTransport",
1716
"init",
1817
"integrations",
18+
# From sentry_sdk.api
19+
"capture_event",
20+
"capture_message",
21+
"capture_exception",
22+
"add_breadcrumb",
23+
"configure_scope",
24+
"push_scope",
25+
"flush",
26+
"last_event_id",
27+
"start_span",
28+
"start_transaction",
29+
"set_tag",
30+
"set_context",
31+
"set_extra",
32+
"set_user",
33+
"set_level",
1934
]
2035

2136
# Initialize the debug support after everything is loaded

sentry_sdk/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def overload(x):
2727
return x
2828

2929

30+
# When changing this, update __all__ in __init__.py too
3031
__all__ = [
3132
"capture_event",
3233
"capture_message",

0 commit comments

Comments
 (0)