Skip to content

Commit 2d594c7

Browse files
docs(init): Fix sentry_sdk.init type hint
The current type hint suggests that all the parameters can be passed as positional arguments, when this is not the case. Only the `dsn` can be passed as a positional argument; the rest must be passed as keyword arguments. This PR makes the type hint reflect the reality of what parameters can be passed to `sentry_sdk.init`.
1 parent 4fb51f2 commit 2d594c7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sentry_sdk/consts.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import itertools
2+
13
from enum import Enum
24
from sentry_sdk._types import TYPE_CHECKING
35

@@ -479,6 +481,7 @@ class ClientConstructor:
479481
def __init__(
480482
self,
481483
dsn=None, # type: Optional[str]
484+
*,
482485
max_breadcrumbs=DEFAULT_MAX_BREADCRUMBS, # type: int
483486
release=None, # type: Optional[str]
484487
environment=None, # type: Optional[str]
@@ -540,7 +543,7 @@ def __init__(
540543

541544

542545
def _get_default_options():
543-
# type: () -> Dict[str, Any]
546+
# type: () -> dict[str, Any]
544547
import inspect
545548

546549
if hasattr(inspect, "getfullargspec"):
@@ -550,7 +553,13 @@ def _get_default_options():
550553

551554
a = getargspec(ClientConstructor.__init__)
552555
defaults = a.defaults or ()
553-
return dict(zip(a.args[-len(defaults) :], defaults))
556+
557+
return dict(
558+
itertools.chain(
559+
zip(a.args[-len(defaults) :], defaults),
560+
a.kwonlydefaults.items(),
561+
)
562+
)
554563

555564

556565
DEFAULT_OPTIONS = _get_default_options()

0 commit comments

Comments
 (0)