[tool.black] # File filtering is taken care of in pre-commit. line-length = 100 target-version = ['py312'] [tool.isort] profile = "black" line_length = 100 lines_between_sections = 1 known_first_party = "sentry" skip = "migrations" [tool.pytest.ini_options] python_files = "test_*.py sentry/testutils/*" # note: When updating the traceback format, make sure to update .github/pytest.json # We don't use the celery pytest plugin. addopts = "--tb=short -p no:celery --nomigrations" # TODO: --import-mode=importlib will become the default soon, # currently we have a few relative imports that don't work with that. markers = [ "snuba: test requires access to snuba", "snuba_ci: test is run in snuba ci", "sentry_metrics: test requires access to sentry metrics", "symbolicator: test requires access to symbolicator", "querybuilder: smoke tests for QueryBuilders", ] filterwarnings = [ # Consider all warnings to be errors other than the ignored ones. "error", # phabricator uses `pkg_resources` apis "ignore:pkg_resources is deprecated as an API", # this warning in protobuf causes a segfault in 3.12+ protocolbuffers/protobuf#15077 "ignore:Type google\\._upb.*", # TODO: we should fix these, but for now there's a lot "ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated.*", "ignore:datetime.datetime.utcnow\\(\\) is deprecated.*", # The following warning filters are for pytest only. "ignore:.*sentry.digests.backends.dummy.DummyBackend.*:sentry.utils.warnings.UnsupportedBackend", # pytest has not yet implemented the replacement for this yet "ignore:The --looponfail command line argument.*", ] looponfailroots = ["src", "tests"] [tool.mypy] python_version = "3.12" mypy_path = ["fixtures/stubs-for-mypy"] plugins = [ "pydantic.mypy", "mypy_django_plugin.main", "tools.mypy_helpers.plugin", ] files = ["."] exclude = ["^.venv/", "^venv/", "^self-hosted/"] # minimal strictness settings check_untyped_defs = true no_implicit_reexport = true warn_unreachable = true warn_unused_configs = true warn_unused_ignores = true warn_redundant_casts = true enable_error_code = ["ignore-without-code", "redundant-self"] [tool.django-stubs] django_settings_module = "sentry.conf.server_mypy" # these have py.typed but incorrect types [[tool.mypy.overrides]] module = [ # TODO: these cause type errors when followed "snuba_sdk.*", ] follow_imports = "skip" # python3 -m tools.mypy_helpers.make_stub_ignores # begin: missing 3rd party stubs # - add .pyi files to fixtures/stubs-for-mypy # - or find a 3rd party stub [[tool.mypy.overrides]] module = [ "boto3.*", "botocore.client.*", "botocore.exceptions.*", "celery.*", "confluent_kafka.*", "cssselect.*", "django_zero_downtime_migrations.backends.postgres.schema.*", "docker.*", "fido2.*", "google.auth.*", "google.cloud.*", "google.resumable_media.common.*", "google.rpc.status_pb2.*", "kombu.*", "mistune.*", "onelogin.saml2.auth.*", "onelogin.saml2.constants.*", "onelogin.saml2.idp_metadata_parser.*", "phabricator.*", "rb.*", "requests_oauthlib.*", "sqlparse.*", "statsd.*", "u2flib_server.model.*", "unidiff.*", ] ignore_missing_imports = true # end: missing 3rd party stubs # python3 -m tools.mypy_helpers.make_module_ignores # begin: sentry modules with typing issues # - remove the module from the list and fix the issues! # - python3 -m tools.mypy_helpers.find_easiest_modules [[tool.mypy.overrides]] module = [ "sentry.api.base", "sentry.api.bases.organization_events", "sentry.api.bases.team", "sentry.api.endpoints.accept_organization_invite", "sentry.api.endpoints.auth_config", "sentry.api.endpoints.codeowners", "sentry.api.endpoints.codeowners.index", "sentry.api.endpoints.event_attachments", "sentry.api.endpoints.group_integration_details", "sentry.api.endpoints.group_integrations", "sentry.api.endpoints.index", "sentry.api.endpoints.internal.mail", "sentry.api.endpoints.organization_details", "sentry.api.endpoints.organization_events_facets_performance", "sentry.api.endpoints.organization_events_meta", "sentry.api.endpoints.organization_events_spans_performance", "sentry.api.endpoints.organization_index", "sentry.api.endpoints.organization_issues_count", "sentry.api.endpoints.organization_member.details", "sentry.api.endpoints.organization_member.index", "sentry.api.endpoints.organization_member.requests.invite.details", "sentry.api.endpoints.organization_onboarding_continuation_email", "sentry.api.endpoints.organization_projects", "sentry.api.endpoints.organization_releases", "sentry.api.endpoints.organization_request_project_creation", "sentry.api.endpoints.organization_search_details", "sentry.api.endpoints.organization_stats", "sentry.api.endpoints.project_index", "sentry.api.endpoints.project_ownership", "sentry.api.endpoints.project_release_files", "sentry.api.endpoints.project_repo_path_parsing", "sentry.api.endpoints.project_rules_configuration", "sentry.api.endpoints.project_transaction_names", "sentry.api.endpoints.team_details", "sentry.api.endpoints.user_subscriptions", "sentry.api.helpers.group_index.index", "sentry.api.invite_helper", "sentry.api.issue_search", "sentry.api.paginator", "sentry.api.permissions", "sentry.api.serializers.models.auth_provider", "sentry.api.serializers.models.event", "sentry.api.serializers.models.group", "sentry.api.serializers.models.group_stream", "sentry.api.serializers.models.organization", "sentry.api.serializers.models.plugin", "sentry.api.serializers.models.project", "sentry.api.serializers.models.role", "sentry.api.serializers.models.rule", "sentry.api.serializers.rest_framework.mentions", "sentry.auth.helper", "sentry.auth.provider", "sentry.auth.system", "sentry.db.mixin", "sentry.db.postgres.base", "sentry.discover.endpoints.discover_key_transactions", "sentry.eventstore.models", "sentry.grouping.strategies.legacy", "sentry.identity.bitbucket.provider", "sentry.identity.gitlab.provider", "sentry.identity.oauth2", "sentry.identity.pipeline", "sentry.identity.providers.dummy", "sentry.incidents.endpoints.bases", "sentry.incidents.endpoints.organization_alert_rule_details", "sentry.incidents.endpoints.organization_alert_rule_index", "sentry.incidents.endpoints.organization_incident_index", "sentry.incidents.subscription_processor", "sentry.incidents.tasks", "sentry.integrations.aws_lambda.integration", "sentry.integrations.bitbucket.client", "sentry.integrations.bitbucket.installed", "sentry.integrations.bitbucket.integration", "sentry.integrations.bitbucket.issues", "sentry.integrations.bitbucket.uninstalled", "sentry.integrations.bitbucket_server.client", "sentry.integrations.bitbucket_server.integration", "sentry.integrations.example.integration", "sentry.integrations.example.repository", "sentry.integrations.github.client", "sentry.integrations.github.integration", "sentry.integrations.github.issues", "sentry.integrations.github_enterprise.integration", "sentry.integrations.gitlab.client", "sentry.integrations.gitlab.integration", "sentry.integrations.gitlab.issues", "sentry.integrations.jira.client", "sentry.integrations.jira.integration", "sentry.integrations.jira.views.base", "sentry.integrations.jira.webhooks.base", "sentry.integrations.jira.webhooks.issue_updated", "sentry.integrations.jira_server.client", "sentry.integrations.jira_server.integration", "sentry.integrations.metric_alerts", "sentry.integrations.msteams.actions.form", "sentry.integrations.msteams.client", "sentry.integrations.msteams.integration", "sentry.integrations.msteams.notifications", "sentry.integrations.notifications", "sentry.integrations.pagerduty.actions.form", "sentry.integrations.pagerduty.client", "sentry.integrations.pagerduty.integration", "sentry.integrations.pipeline", "sentry.integrations.slack.actions.form", "sentry.integrations.slack.integration", "sentry.integrations.slack.message_builder.notifications.issues", "sentry.integrations.slack.notifications", "sentry.integrations.slack.unfurl.discover", "sentry.integrations.slack.utils.channel", "sentry.integrations.slack.utils.users", "sentry.integrations.slack.webhooks.command", "sentry.integrations.slack.webhooks.event", "sentry.integrations.utils.commit_context", "sentry.integrations.utils.sync", "sentry.integrations.vercel.client", "sentry.integrations.vercel.integration", "sentry.integrations.vercel.webhook", "sentry.integrations.vsts.client", "sentry.integrations.vsts.integration", "sentry.integrations.vsts.issues", "sentry.integrations.vsts.repository", "sentry.integrations.vsts_extension.integration", "sentry.issues.search", "sentry.middleware.auth", "sentry.middleware.ratelimit", "sentry.middleware.superuser", "sentry.monitors.consumers.monitor_consumer", "sentry.monitors.endpoints.base", "sentry.monitors.endpoints.organization_monitor_index", "sentry.net.http", "sentry.net.socket", "sentry.notifications.notifications.activity.base", "sentry.notifications.notifications.integration_nudge", "sentry.pipeline.base", "sentry.pipeline.views.base", "sentry.pipeline.views.nested", "sentry.plugins.bases.data_forwarding", "sentry.plugins.bases.issue", "sentry.plugins.bases.issue2", "sentry.plugins.bases.notify", "sentry.plugins.config", "sentry.plugins.endpoints", "sentry.receivers.releases", "sentry.release_health.metrics_sessions_v2", "sentry.replays.endpoints.project_replay_clicks_index", "sentry.rules.actions.integrations.base", "sentry.rules.actions.integrations.create_ticket.form", "sentry.rules.actions.integrations.create_ticket.utils", "sentry.rules.filters.assigned_to", "sentry.rules.history.preview", "sentry.scim.endpoints.members", "sentry.scim.endpoints.teams", "sentry.scim.endpoints.utils", "sentry.search.events.builder.errors", "sentry.search.events.builder.metrics", "sentry.search.events.datasets.filter_aliases", "sentry.search.events.datasets.metrics_layer", "sentry.search.events.fields", "sentry.search.events.filter", "sentry.search.snuba.executors", "sentry.search.utils", "sentry.sentry_apps.installations", "sentry.sentry_metrics.indexer.postgres.postgres_v2", "sentry.shared_integrations.client.proxy", "sentry.snuba.errors", "sentry.snuba.issue_platform", "sentry.snuba.metrics.datasource", "sentry.snuba.metrics.fields.base", "sentry.snuba.metrics.query_builder", "sentry.snuba.spans_metrics", "sentry.tagstore.snuba.backend", "sentry.tagstore.types", "sentry.tasks.auth", "sentry.tasks.base", "sentry.testutils.cases", "sentry.utils.auth", "sentry.utils.committers", "sentry.web.forms.accounts", "sentry.web.frontend.auth_login", "sentry.web.frontend.auth_organization_login", "sentry.web.frontend.base", "sentry.web.frontend.oauth_authorize", "sentry.web.frontend.react_page", "sentry.web.frontend.setup_wizard", "sentry.web.frontend.shared_group_details", "sentry_plugins.bitbucket.client", "sentry_plugins.bitbucket.mixins", "sentry_plugins.github.plugin", "sentry_plugins.jira.plugin", "tests.sentry.api.helpers.test_group_index", "tests.sentry.api.test_base", "tests.sentry.api.test_event_search", "tests.sentry.issues.test_utils", ] disable_error_code = [ "arg-type", "assignment", "attr-defined", "call-arg", "call-overload", "dict-item", "index", "misc", "operator", "override", "return-value", "typeddict-item", "typeddict-unknown-key", "union-attr", "unreachable", "var-annotated", ] # end: sentry modules with typing issues # begin: stronger typing [[tool.mypy.overrides]] module = [ "fixtures.safe_migrations_apps.*", "sentry.analytics.*", "sentry.api.endpoints.integrations.sentry_apps.installation.external_issue.*", "sentry.api.endpoints.project_backfill_similar_issues_embeddings_records", "sentry.api.endpoints.release_thresholds.health_checks.*", "sentry.api.endpoints.relocations.artifacts.*", "sentry.api.helpers.deprecation", "sentry.api.helpers.source_map_helper", "sentry.api.serializers.models.organization_member.*", "sentry.audit_log.services.*", "sentry.auth.services.*", "sentry.auth.view", "sentry.buffer.*", "sentry.build.*", "sentry.data_secrecy.models.*", "sentry.data_secrecy.service.*", "sentry.db.models.fields.citext", "sentry.db.models.fields.foreignkey", "sentry.db.models.fields.hybrid_cloud_foreign_key", "sentry.db.models.fields.types", "sentry.db.models.manager.*", "sentry.db.models.paranoia", "sentry.db.models.utils", "sentry.deletions.*", "sentry.digests.*", "sentry.digests.notifications", "sentry.dynamic_sampling.models.*", "sentry.dynamic_sampling.rules.biases.*", "sentry.dynamic_sampling.rules.combinators.*", "sentry.dynamic_sampling.rules.helpers.*", "sentry.dynamic_sampling.tasks.helpers.*", "sentry.eventstore.reprocessing.*", "sentry.eventstore.reprocessing.redis", "sentry.eventstream.*", "sentry.eventtypes.error", "sentry.feedback.migrations.*", "sentry.flags.migrations.*", "sentry.grouping.api", "sentry.grouping.component", "sentry.grouping.fingerprinting", "sentry.grouping.fingerprinting.*", "sentry.grouping.grouping_info", "sentry.grouping.ingest.*", "sentry.grouping.parameterization", "sentry.grouping.utils", "sentry.grouping.variants", "sentry.hybridcloud.*", "sentry.identity.discord.*", "sentry.identity.github_enterprise.*", "sentry.identity.services.*", "sentry.identity.vsts_extension.*", "sentry.incidents.utils.*", "sentry.ingest.slicing", "sentry.integrations.discord.actions.*", "sentry.integrations.discord.message_builder.base.component.*", "sentry.integrations.discord.message_builder.base.embed.*", "sentry.integrations.discord.utils.*", "sentry.integrations.discord.views.*", "sentry.integrations.discord.webhooks.*", "sentry.integrations.github.actions.*", "sentry.integrations.github_enterprise.actions.*", "sentry.integrations.jira.actions.*", "sentry.integrations.jira.endpoints.*", "sentry.integrations.jira.models.*", "sentry.integrations.jira_server.actions.*", "sentry.integrations.jira_server.utils.*", "sentry.integrations.models.integration_feature", "sentry.integrations.project_management.*", "sentry.integrations.repository.*", "sentry.integrations.services.*", "sentry.integrations.slack.threads.*", "sentry.integrations.slack.views.*", "sentry.integrations.vsts.actions.*", "sentry.integrations.vsts.tasks.*", "sentry.integrations.web.debug.*", "sentry.issues", "sentry.issues.analytics", "sentry.issues.apps", "sentry.issues.constants", "sentry.issues.endpoints", "sentry.issues.endpoints.actionable_items", "sentry.issues.endpoints.group_activities", "sentry.issues.endpoints.group_event_details", "sentry.issues.endpoints.group_events", "sentry.issues.endpoints.group_notes", "sentry.issues.endpoints.group_notes_details", "sentry.issues.endpoints.group_similar_issues_embeddings", "sentry.issues.endpoints.group_tombstone", "sentry.issues.endpoints.group_tombstone_details", "sentry.issues.endpoints.organization_eventid", "sentry.issues.endpoints.organization_group_index", "sentry.issues.endpoints.organization_group_index_stats", "sentry.issues.endpoints.organization_group_search_views", "sentry.issues.endpoints.organization_release_previous_commits", "sentry.issues.endpoints.organization_searches", "sentry.issues.endpoints.organization_shortid", "sentry.issues.endpoints.project_event_details", "sentry.issues.endpoints.project_events", "sentry.issues.endpoints.project_group_index", "sentry.issues.endpoints.project_group_stats", "sentry.issues.endpoints.project_stacktrace_link", "sentry.issues.endpoints.related_issues", "sentry.issues.endpoints.shared_group_details", "sentry.issues.endpoints.team_groups_old", "sentry.issues.escalating", "sentry.issues.escalating_group_forecast", "sentry.issues.escalating_issues_alg", "sentry.issues.forecasts", "sentry.issues.ignored", "sentry.issues.ingest", "sentry.issues.issue_occurrence", "sentry.issues.json_schemas", "sentry.issues.merge", "sentry.issues.occurrence_consumer", "sentry.issues.ongoing", "sentry.issues.priority", "sentry.issues.producer", "sentry.issues.query", "sentry.issues.receivers", "sentry.issues.related.*", "sentry.issues.run", "sentry.issues.services.*", "sentry.issues.status_change", "sentry.issues.status_change_consumer", "sentry.issues.status_change_message", "sentry.issues.update_inbox", "sentry.lang.java.processing", "sentry.llm.*", "sentry.migrations.*", "sentry.models.activity", "sentry.models.event", "sentry.models.eventattachment", "sentry.models.groupassignee", "sentry.models.grouphistory", "sentry.models.groupsubscription", "sentry.models.options.*", "sentry.monkey.*", "sentry.nodestore.*", "sentry.nodestore.base", "sentry.nodestore.bigtable.backend", "sentry.nodestore.django.backend", "sentry.nodestore.django.models", "sentry.nodestore.filesystem.backend", "sentry.nodestore.models", "sentry.notifications.services.*", "sentry.organizations.*", "sentry.ownership.*", "sentry.plugins.base.response", "sentry.plugins.base.view", "sentry.plugins.validators.*", "sentry.post_process_forwarder.*", "sentry.profiles.*", "sentry.projects.*", "sentry.queue.*", "sentry.ratelimits.leaky_bucket", "sentry.relay.config.metric_extraction", "sentry.relay.types.*", "sentry.release_health.release_monitor.*", "sentry.relocation.services.relocation_export.*", "sentry.remote_subscriptions.migrations.*", "sentry.replays.consumers.*", "sentry.replays.lib.new_query.*", "sentry.replays.migrations.*", "sentry.reprocessing2", "sentry.roles.*", "sentry.rules.actions.sentry_apps.*", "sentry.rules.conditions.*", "sentry.rules.history.endpoints.*", "sentry.runner.*", "sentry.search.snuba.backend", "sentry.security.*", "sentry.seer.similarity.*", "sentry.sentry_apps.external_issues.*", "sentry.sentry_apps.services.*", "sentry.sentry_apps.utils.*", "sentry.sentry_apps.web.*", "sentry.sentry_metrics.consumers.indexer.*", "sentry.sentry_metrics.indexer.limiters.*", "sentry.shared_integrations.exceptions.*", "sentry.slug.*", "sentry.snuba.metrics.extraction", "sentry.snuba.metrics.naming_layer.*", "sentry.snuba.query_subscriptions.*", "sentry.spans.grouping.*", "sentry.stacktraces.platform", "sentry.tasks.beacon", "sentry.tasks.commit_context", "sentry.tasks.embeddings_grouping.backfill_seer_grouping_records_for_project", "sentry.tasks.on_demand_metrics", "sentry.tasks.reprocessing2", "sentry.tasks.store", "sentry.taskworker.*", "sentry.tempest.endpoints.*", "sentry.tempest.migrations.*", "sentry.testutils.helpers.task_runner", "sentry.testutils.skips", "sentry.toolbar.utils.*", "sentry.trash.*", "sentry.types.*", "sentry.uptime.migrations.*", "sentry.usage_accountant.*", "sentry.users.*", "sentry.utils.arroyo", "sentry.utils.assets", "sentry.utils.audit", "sentry.utils.celery", "sentry.utils.codeowners", "sentry.utils.colors", "sentry.utils.email.*", "sentry.utils.env", "sentry.utils.event", "sentry.utils.files", "sentry.utils.function_cache", "sentry.utils.geo", "sentry.utils.imports", "sentry.utils.iterators", "sentry.utils.javascript", "sentry.utils.kvstore.*", "sentry.utils.lazy_service_wrapper", "sentry.utils.locking.*", "sentry.utils.migrations", "sentry.utils.numbers", "sentry.utils.otp", "sentry.utils.performance_issues.detectors.*", "sentry.utils.performance_issues.performance_detection", "sentry.utils.pubsub", "sentry.utils.redis", "sentry.utils.redis_metrics", "sentry.utils.sdk_crashes.*", "sentry.utils.sentry_apps.*", "sentry.utils.services", "sentry.utils.sms", "sentry.utils.snowflake", "sentry.utils.urls", "sentry.utils.uwsgi", "sentry.utils.zip", "sentry.web.frontend.auth_provider_login", "sentry.web.frontend.cli", "sentry.web.frontend.csv", "sentry.web.frontend.mixins.*", "sentry.workflow_engine.handlers.action.*", "sentry.workflow_engine.handlers.condition.*", "sentry.workflow_engine.migrations.*", "sentry_plugins.base", "social_auth.migrations.*", "sudo.*", "tests.sentry.audit_log.services.*", "tests.sentry.deletions.test_group", "tests.sentry.event_manager.test_event_manager", "tests.sentry.grouping.ingest.test_seer", "tests.sentry.grouping.test_fingerprinting", "tests.sentry.hybridcloud.*", "tests.sentry.incidents.serializers.*", "tests.sentry.integrations.msteams.webhook.*", "tests.sentry.integrations.repository.base.*", "tests.sentry.integrations.repository.issue_alert.*", "tests.sentry.integrations.slack.threads.*", "tests.sentry.issues", "tests.sentry.issues.endpoints", "tests.sentry.issues.endpoints.test_actionable_items", "tests.sentry.issues.endpoints.test_group_activities", "tests.sentry.issues.endpoints.test_group_details", "tests.sentry.issues.endpoints.test_group_event_details", "tests.sentry.issues.endpoints.test_group_events", "tests.sentry.issues.endpoints.test_group_hashes", "tests.sentry.issues.endpoints.test_group_notes", "tests.sentry.issues.endpoints.test_group_notes_details", "tests.sentry.issues.endpoints.test_group_similar_issues_embeddings", "tests.sentry.issues.endpoints.test_group_tombstone", "tests.sentry.issues.endpoints.test_group_tombstone_details", "tests.sentry.issues.endpoints.test_organization_group_search_views", "tests.sentry.issues.endpoints.test_organization_searches", "tests.sentry.issues.endpoints.test_organization_shortid", "tests.sentry.issues.endpoints.test_project_group_stats", "tests.sentry.issues.endpoints.test_project_stacktrace_link", "tests.sentry.issues.endpoints.test_related_issues", "tests.sentry.issues.endpoints.test_shared_group_details", "tests.sentry.issues.endpoints.test_source_map_debug", "tests.sentry.issues.endpoints.test_team_groups_old", "tests.sentry.issues.test_attributes", "tests.sentry.issues.test_escalating", "tests.sentry.issues.test_escalating_issues_alg", "tests.sentry.issues.test_group_attributes_dataset", "tests.sentry.issues.test_grouptype", "tests.sentry.issues.test_ignored", "tests.sentry.issues.test_ingest", "tests.sentry.issues.test_issue_occurrence", "tests.sentry.issues.test_issue_velocity", "tests.sentry.issues.test_json_schemas", "tests.sentry.issues.test_merge", "tests.sentry.issues.test_occurrence_consumer", "tests.sentry.issues.test_ongoing", "tests.sentry.issues.test_priority", "tests.sentry.issues.test_producer", "tests.sentry.issues.test_run", "tests.sentry.issues.test_search_issues_dataset", "tests.sentry.issues.test_status_change", "tests.sentry.issues.test_status_change_consumer", "tests.sentry.issues.test_update_inbox", "tests.sentry.organizations.*", "tests.sentry.ownership.*", "tests.sentry.post_process_forwarder.*", "tests.sentry.profiling.*", "tests.sentry.queue.*", "tests.sentry.ratelimits.test_leaky_bucket", "tests.sentry.relay.config.test_metric_extraction", "tests.sentry.replays.unit.lib.*", "tests.sentry.rules.actions.base.*", "tests.sentry.security.*", "tests.sentry.snuba.metrics.test_metrics_query_layer.*", "tests.sentry.tasks.integrations.*", "tests.sentry.tasks.test_on_demand_metrics", "tests.sentry.types.*", "tests.sentry.types.test_actor", "tests.sentry.types.test_region", "tests.sentry.usage_accountant.*", "tests.sentry.users.services.*", "tests.sentry.utils.mockdata.*", "tests.sentry.web.frontend.test_cli", "tools.*", ] disallow_any_generics = true disallow_untyped_defs = true # end: stronger typing