|
2 | 2 |
|
3 | 3 | MYPY = False
|
4 | 4 | if MYPY:
|
5 |
| - from mypy_extensions import TypedDict |
6 | 5 | from typing import Optional
|
7 | 6 | from typing import Callable
|
8 | 7 | from typing import Union
|
9 | 8 | from typing import List
|
10 | 9 | from typing import Type
|
| 10 | + from typing import Dict |
| 11 | + from typing import Any |
11 | 12 |
|
12 | 13 | from sentry_sdk.transport import Transport
|
13 | 14 | from sentry_sdk.integrations import Integration
|
14 | 15 |
|
15 | 16 | from sentry_sdk.utils import Event, EventProcessor, BreadcrumbProcessor
|
16 | 17 |
|
17 |
| - ClientOptions = TypedDict( |
18 |
| - "ClientOptions", |
19 |
| - { |
20 |
| - "dsn": Optional[str], |
21 |
| - "with_locals": bool, |
22 |
| - "max_breadcrumbs": int, |
23 |
| - "release": Optional[str], |
24 |
| - "environment": Optional[str], |
25 |
| - "server_name": Optional[str], |
26 |
| - "shutdown_timeout": int, |
27 |
| - "integrations": List[Integration], |
28 |
| - "in_app_include": List[str], |
29 |
| - "in_app_exclude": List[str], |
30 |
| - "default_integrations": bool, |
31 |
| - "dist": Optional[str], |
32 |
| - "transport": Optional[ |
33 |
| - Union[Transport, Type[Transport], Callable[[Event], None]] |
34 |
| - ], |
35 |
| - "sample_rate": int, |
36 |
| - "send_default_pii": bool, |
37 |
| - "http_proxy": Optional[str], |
38 |
| - "https_proxy": Optional[str], |
39 |
| - "ignore_errors": List[Union[type, str]], |
40 |
| - "request_bodies": str, |
41 |
| - "before_send": Optional[EventProcessor], |
42 |
| - "before_breadcrumb": Optional[BreadcrumbProcessor], |
43 |
| - "debug": bool, |
44 |
| - "attach_stacktrace": bool, |
45 |
| - "ca_certs": Optional[str], |
46 |
| - "propagate_traces": bool, |
47 |
| - }, |
48 |
| - total=False, |
49 |
| - ) |
50 | 18 |
|
51 |
| - |
52 |
| -VERSION = "0.9.2" |
53 | 19 | DEFAULT_SERVER_NAME = socket.gethostname() if hasattr(socket, "gethostname") else None
|
54 |
| -DEFAULT_OPTIONS = { |
55 |
| - "dsn": None, |
56 |
| - "with_locals": True, |
57 |
| - "max_breadcrumbs": 100, |
58 |
| - "release": None, |
59 |
| - "environment": None, |
60 |
| - "server_name": DEFAULT_SERVER_NAME, |
61 |
| - "shutdown_timeout": 2.0, |
62 |
| - "integrations": [], |
63 |
| - "in_app_include": [], |
64 |
| - "in_app_exclude": [], |
65 |
| - "default_integrations": True, |
66 |
| - "dist": None, |
67 |
| - "transport": None, |
68 |
| - "sample_rate": 1.0, |
69 |
| - "send_default_pii": False, |
70 |
| - "http_proxy": None, |
71 |
| - "https_proxy": None, |
72 |
| - "ignore_errors": [], |
73 |
| - "request_bodies": "medium", |
74 |
| - "before_send": None, |
75 |
| - "before_breadcrumb": None, |
76 |
| - "debug": False, |
77 |
| - "attach_stacktrace": False, |
78 |
| - "ca_certs": None, |
79 |
| - "propagate_traces": True, |
80 |
| -} |
81 | 20 |
|
82 | 21 |
|
| 22 | +# This type exists to trick mypy and PyCharm into thinking `init` and `Client` |
| 23 | +# take these arguments (even though they take opaque **kwargs) |
| 24 | +class ClientConstructor(object): |
| 25 | + def __init__( |
| 26 | + self, |
| 27 | + dsn=None, # type: Optional[str] |
| 28 | + with_locals=True, # type: bool |
| 29 | + max_breadcrumbs=100, # type: int |
| 30 | + release=None, # type: Optional[str] |
| 31 | + environment=None, # type: Optional[str] |
| 32 | + server_name=DEFAULT_SERVER_NAME, # type: Optional[str] |
| 33 | + shutdown_timeout=2, # type: int |
| 34 | + integrations=[], # type: List[Integration] |
| 35 | + in_app_include=[], # type: List[str] |
| 36 | + in_app_exclude=[], # type: List[str] |
| 37 | + default_integrations=True, # type: bool |
| 38 | + dist=None, # type: Optional[str] |
| 39 | + transport=None, # type: Optional[Union[Transport, Type[Transport], Callable[[Event], None]]] |
| 40 | + sample_rate=1.0, # type: float |
| 41 | + send_default_pii=False, # type: bool |
| 42 | + http_proxy=None, # type: Optional[str] |
| 43 | + https_proxy=None, # type: Optional[str] |
| 44 | + ignore_errors=[], # type: List[Union[type, str]] |
| 45 | + request_bodies="medium", # type: str |
| 46 | + before_send=None, # type: Optional[EventProcessor] |
| 47 | + before_breadcrumb=None, # type: Optional[BreadcrumbProcessor] |
| 48 | + debug=False, # type: bool |
| 49 | + attach_stacktrace=False, # type: bool |
| 50 | + ca_certs=None, # type: Optional[str] |
| 51 | + propagate_traces=True, # type: bool |
| 52 | + ): |
| 53 | + # type: (...) -> None |
| 54 | + pass |
| 55 | + |
| 56 | + |
| 57 | +def _get_default_options(): |
| 58 | + # type: () -> Dict[str, Any] |
| 59 | + import inspect |
| 60 | + |
| 61 | + a = inspect.getargspec(ClientConstructor.__init__) |
| 62 | + return dict(zip(a.args[-len(a.defaults) :], a.defaults)) |
| 63 | + |
| 64 | + |
| 65 | +DEFAULT_OPTIONS = _get_default_options() |
| 66 | +del _get_default_options |
| 67 | + |
| 68 | + |
| 69 | +VERSION = "0.9.2" |
83 | 70 | SDK_INFO = {
|
84 | 71 | "name": "sentry.python",
|
85 | 72 | "version": VERSION,
|
|
0 commit comments