fix: types for logging integration args#444
Conversation
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)]) ```
```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
```
|
What do you pass to integrations other than a list? I'd like to prevent people from passing in non-resettable iterators because I make no guarantees about how often I iterate over the sequence. |
|
Nvm sequence seems fine for this. |
|
The changes LGTM. With regards to For inputs, e.g. function arguments, prefer For outputs, give the specific type (e.g. Also, when taking a callback, the situation is reversed. |
|
Thanks! |
The sdk supports disabling the LoggingIntegration by passing
Noneasarguments; however, the current types require ints.
This behavior is noted in the docs:
https://docs.sentry.io/platforms/python/logging/#options
edit: when adding
# type: ignoreI found a second issue with the argumentintegrationswhich mypy recommended as typing asSequenceinstead ofList. This fixed the type error.