The recommended way to increase values like MAX_DATABAG_BREADTH on the serializer is to assign directly to the variables.
import sentry_sdk
import sentry_sdk.serializer
sentry_sdk.init(
…
)
sentry_sdk.serializer.MAX_DATABAG_DEPTH = 15 # defaults to 5
sentry_sdk.serializer.MAX_DATABAG_BREADTH = 20 # defaults to 10
These variables however lack a type annotation where they are defined
causing some type-checkers (notably
ty) to infer the type of these as literal (e.g.
Literal[10]) instead of int, causing the type-checker to throw errors when you reassign the variable.
By type-annotating global config variables like these with int (or their appropriate type) it becomes obvious for type-checkers that they are mutable and can be reassigned.
The recommended way to increase values like
MAX_DATABAG_BREADTHon the serializer is to assign directly to the variables.These variables however lack a type annotation where they are defined
sentry-python/sentry_sdk/serializer.py
Line 47 in 990839c
causing some type-checkers (notably ty) to infer the type of these as literal (e.g.
Literal[10]) instead of int, causing the type-checker to throw errors when you reassign the variable.By type-annotating global config variables like these with int (or their appropriate type) it becomes obvious for type-checkers that they are mutable and can be reassigned.