Skip to content

Add type annotations to global config variables #7503

Description

@RasmusNygren

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

MAX_DATABAG_BREADTH = 10

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions