From 62206bb8d67fb69be6d5e93e83436df0fbe8d331 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Wed, 21 Feb 2024 15:49:07 -0800 Subject: [PATCH 01/10] feat(typing): add possibly undefined check to mypy --- pyproject.toml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 01409549597071..5eca3c63dbc5d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,10 @@ warn_unused_ignores = true warn_redundant_casts = true enable_error_code = ["ignore-without-code"] +# check for possibly unbound variables + +enable_error_code = ["possibly-undefined"] + [tool.django-stubs] django_settings_module = "sentry.conf.server_mypy" @@ -610,6 +614,7 @@ disable_error_code = [ "union-attr", "unreachable", "var-annotated", + "possibly-undefined", ] # end: sentry modules with typing issues @@ -644,3 +649,51 @@ module = [ disallow_any_generics = true disallow_untyped_defs = true # end: stronger typing + +# beginning: modules with possibly undefined variables +[[tool.mypy.overrides]] +module = [ + "sentry.api.helpers.span_analysis", + "sentry.http", + "sentry.nodestore.base", + "sentry.models.groupsubscription", + "sentry.tasks.post_process", + "sentry.tasks.assemble", + "sentry.tasks.commit_context", + "sentry.utils.mockdata.core", + "sentry.snuba.metrics_performance", + "sentry.snuba.metrics_layer.query", + "sentry.runner.commands.devservices", + "sentry.middleware.integrations.tasks", + "sentry.integrations.github.installation", + "sentry.api.endpoints.project_filter_details", + "sentry.runner.commands.cleanup", + "sentry.services.hybrid_cloud.import_export.impl", + "sentry.runner.commands.backup", + "sentry.api.endpoints.relocations.unpause", + "sentry.integrations.slack.actions.notification", + "sentry.api.endpoints.release_thresholds.release_threshold_status_index", + "tests.sentry.tasks.test_reprocessing2", + "tests.snuba.tsdb.test_tsdb_backend", + "tests.snuba.tagstore.test_tagstore_backend", + "tests.snuba.api.endpoints.test_project_group_index", + "tests.snuba.api.endpoints.test_organization_group_index", + "tests.snuba.api.endpoints.test_organization_events_stats", + "tests.snuba.api.endpoints.test_organization_events", + "tests.snuba.api.endpoints.test_group_events", + "tests.sentry.web.frontend.test_twofactor", + "tests.sentry.utils.test_event", + "tests.sentry.tasks.test_auto_ongoing_issues", + "tests.sentry.rules.history.test_preview", + "tests.sentry.replays.test_organization_replay_count", + "tests.sentry.integrations.github.test_issues", + "tests.sentry.integrations.bitbucket.test_issues", + "tests.sentry.api.endpoints.test_project_rules", + "tests.sentry.api.endpoints.test_debug_files", + "tests.sentry.models.test_groupsnooze", + "tests.sentry.issues.test_escalating", + "tests.apidocs.endpoints.events.test_group_issue_details", + "tests.apidocs.endpoints.events.test_group_events", +] +disable_error_code = ["possibly-undefined"] +# end: modules with possibly undefined variables From 8ff247cd9452d6cd0728b03af5240b6929b2a590 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Thu, 22 Feb 2024 08:13:53 -0800 Subject: [PATCH 02/10] remove unrelated change, remove comment --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5eca3c63dbc5d2..810e5b171d07da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,8 +66,6 @@ warn_unused_ignores = true warn_redundant_casts = true enable_error_code = ["ignore-without-code"] -# check for possibly unbound variables - enable_error_code = ["possibly-undefined"] [tool.django-stubs] From a2ca47a8cfd80e6f6b728197b50ce313bafb47c1 Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:01:38 +0000 Subject: [PATCH 03/10] :knife: regenerate mypy module blocklist --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 810e5b171d07da..ddfee80b803e5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -606,13 +606,13 @@ disable_error_code = [ "misc", "operator", "override", + "possibly-undefined", "return-value", "typeddict-item", "typeddict-unknown-key", "union-attr", "unreachable", "var-annotated", - "possibly-undefined", ] # end: sentry modules with typing issues From 575cfbe71589543b6c510b2b923612b2c6e13597 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Tue, 27 Feb 2024 20:23:30 +0000 Subject: [PATCH 04/10] add fix script --- pyproject.toml | 73 ++++++++++--------- tools/mypy_helpers/make_module_ignores.py | 45 ++++++++++++ .../mypy_without_ignore_possibly_undefined.py | 26 +++++++ 3 files changed, 109 insertions(+), 35 deletions(-) create mode 100644 tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py diff --git a/pyproject.toml b/pyproject.toml index ddfee80b803e5b..2ce6c767d39d37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -259,6 +259,7 @@ module = [ "sentry.auth.providers.saml2.views", "sentry.auth.system", "sentry.auth.view", + "sentry.buffer.redis", "sentry.db.mixin", "sentry.db.models.manager.base", "sentry.db.models.paranoia", @@ -407,6 +408,7 @@ module = [ "sentry.plugins.providers.repository", "sentry.profiles.task", "sentry.profiles.utils", + "sentry.quotas.redis", "sentry.receivers.releases", "sentry.receivers.sentry_apps", "sentry.release_health.metrics_sessions_v2", @@ -588,10 +590,13 @@ module = [ "tests.sentry.ingest.test_slicing", "tests.sentry.integrations.github.test_client", "tests.sentry.integrations.slack.test_requests", + "tests.sentry.issues.endpoints.test_group_events", + "tests.sentry.issues.endpoints.test_organization_group_index", "tests.sentry.issues.test_utils", "tests.sentry.models.test_organizationmember", "tests.sentry.replays.test_project_replay_recording_segment_index", "tests.sentry.tasks.test_post_process", + "tools.mypy_helpers.make_module_ignores", ] disable_error_code = [ "arg-type", @@ -648,50 +653,48 @@ disallow_any_generics = true disallow_untyped_defs = true # end: stronger typing -# beginning: modules with possibly undefined variables +# begin: sentry modules with possibly undefined variables [[tool.mypy.overrides]] module = [ + "sentry.api.endpoints.project_filter_details", + "sentry.api.endpoints.release_thresholds.release_threshold_status_index", + "sentry.api.endpoints.relocations.unpause", "sentry.api.helpers.span_analysis", "sentry.http", - "sentry.nodestore.base", + "sentry.integrations.github.installation", + "sentry.integrations.slack.actions.notification", + "sentry.middleware.integrations.tasks", "sentry.models.groupsubscription", - "sentry.tasks.post_process", + "sentry.nodestore.base", + "sentry.runner.commands.backup", + "sentry.runner.commands.cleanup", + "sentry.runner.commands.devservices", + "sentry.services.hybrid_cloud.import_export.impl", + "sentry.snuba.metrics_layer.query", + "sentry.snuba.metrics_performance", "sentry.tasks.assemble", "sentry.tasks.commit_context", + "sentry.tasks.post_process", "sentry.utils.mockdata.core", - "sentry.snuba.metrics_performance", - "sentry.snuba.metrics_layer.query", - "sentry.runner.commands.devservices", - "sentry.middleware.integrations.tasks", - "sentry.integrations.github.installation", - "sentry.api.endpoints.project_filter_details", - "sentry.runner.commands.cleanup", - "sentry.services.hybrid_cloud.import_export.impl", - "sentry.runner.commands.backup", - "sentry.api.endpoints.relocations.unpause", - "sentry.integrations.slack.actions.notification", - "sentry.api.endpoints.release_thresholds.release_threshold_status_index", - "tests.sentry.tasks.test_reprocessing2", - "tests.snuba.tsdb.test_tsdb_backend", - "tests.snuba.tagstore.test_tagstore_backend", - "tests.snuba.api.endpoints.test_project_group_index", - "tests.snuba.api.endpoints.test_organization_group_index", - "tests.snuba.api.endpoints.test_organization_events_stats", - "tests.snuba.api.endpoints.test_organization_events", - "tests.snuba.api.endpoints.test_group_events", - "tests.sentry.web.frontend.test_twofactor", - "tests.sentry.utils.test_event", - "tests.sentry.tasks.test_auto_ongoing_issues", - "tests.sentry.rules.history.test_preview", - "tests.sentry.replays.test_organization_replay_count", - "tests.sentry.integrations.github.test_issues", - "tests.sentry.integrations.bitbucket.test_issues", - "tests.sentry.api.endpoints.test_project_rules", + "tests.apidocs.endpoints.events.test_group_events", + "tests.apidocs.endpoints.events.test_group_issue_details", "tests.sentry.api.endpoints.test_debug_files", - "tests.sentry.models.test_groupsnooze", + "tests.sentry.api.endpoints.test_project_rules", + "tests.sentry.integrations.bitbucket.test_issues", + "tests.sentry.integrations.github.test_issues", "tests.sentry.issues.test_escalating", - "tests.apidocs.endpoints.events.test_group_issue_details", - "tests.apidocs.endpoints.events.test_group_events", + "tests.sentry.models.test_groupsnooze", + "tests.sentry.replays.test_organization_replay_count", + "tests.sentry.rules.history.test_preview", + "tests.sentry.tasks.test_auto_ongoing_issues", + "tests.sentry.tasks.test_reprocessing2", + "tests.sentry.utils.test_event", + "tests.sentry.web.frontend.test_twofactor", + "tests.snuba.api.endpoints.test_organization_events", + "tests.snuba.api.endpoints.test_organization_events_stats", + "tests.snuba.api.endpoints.test_project_group_index", + "tests.snuba.tagstore.test_tagstore_backend", + "tests.snuba.tsdb.test_tsdb_backend", ] +# end: sentry modules with possibly undefined variables disable_error_code = ["possibly-undefined"] -# end: modules with possibly undefined variables diff --git a/tools/mypy_helpers/make_module_ignores.py b/tools/mypy_helpers/make_module_ignores.py index 414f12080525c9..5e575286371f06 100644 --- a/tools/mypy_helpers/make_module_ignores.py +++ b/tools/mypy_helpers/make_module_ignores.py @@ -57,6 +57,51 @@ def main() -> int: with open("pyproject.toml", "w") as f: f.write(before + begin + generated + end + rest) + # # begin possibly_undefined fixer + shutil.rmtree(".mypy_cache", ignore_errors=True) + + codes = set() + filenames = set() + out = subprocess.run( + ( + sys.executable, + "-m", + "tools.mypy_helpers.mypy_without_ignore_possibly_undefined", + *sys.argv[1:], + ), + capture_output=True, + ) + for line in out.stdout.decode().splitlines(): + filename, _, _ = line.partition(":") + if filename.endswith(".py"): + filenames.add(filename) + if match is not None: + codes.add(match[1]) + + os.makedirs(".artifacts", exist_ok=True) + with open(".artifacts/mypy-all", "wb") as f: + f.write(out.stdout) + + mods = [] + for filename in sorted(filenames): + # TODO: removeprefix / removesuffix python 3.9+ + if filename.endswith(".py"): + filename = filename[: -len(".py")] + if filename.startswith("src/"): + filename = filename[len("src/") :] + if filename.endswith("/__init__"): + filename = filename[: -len("/__init__")] + mods.append(filename.replace("/", ".")) + mods_s = "".join(f' "{mod}",\n' for mod in mods) + generated = f"[[tool.mypy.overrides]]\n" f"module = [\n{mods_s}]\n" + with open("pyproject.toml") as f: + src = f.read() + msg = "sentry modules with possibly undefined variables" + before, begin, rest = src.partition(f"# begin: {msg}\n") + _, end, rest = rest.partition(f"# end: {msg}\n") + with open("pyproject.toml", "w") as f: + f.write(before + begin + generated + end + rest) + return 0 diff --git a/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py b/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py new file mode 100644 index 00000000000000..fc7b15718135b4 --- /dev/null +++ b/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py @@ -0,0 +1,26 @@ +from __future__ import annotations + +import os.path +import subprocess +import sys +import tempfile + + +def main() -> int: + with open("pyproject.toml") as f: + src = f.read() + msg = "sentry modules with possibly undefined variables" + before, begin, rest = src.partition(f"# begin: {msg}\n") + _, end, rest = rest.partition(f"# end: {msg}\n") + + with tempfile.TemporaryDirectory() as tmpdir: + cfg = os.path.join(tmpdir, "mypy.toml") + print(before + begin + end + rest) + with open(cfg, "w") as f: + f.write(before + begin + end + rest) + + return subprocess.call(("mypy", "--config", cfg, *sys.argv[1:])) + + +if __name__ == "__main__": + raise SystemExit(main()) From f25f148573307359a0cb4f23e85d4a14e3c54c46 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Tue, 27 Feb 2024 20:54:42 +0000 Subject: [PATCH 05/10] one more file to ignore list --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 2ce6c767d39d37..c6366d9f6c5b09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -595,6 +595,7 @@ module = [ "tests.sentry.issues.test_utils", "tests.sentry.models.test_organizationmember", "tests.sentry.replays.test_project_replay_recording_segment_index", + "tests.sentry.tasks.test_daily_summary", "tests.sentry.tasks.test_post_process", "tools.mypy_helpers.make_module_ignores", ] From 19701d1848e13a6206aa8c520e3a35b3a2a218a7 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Wed, 21 Feb 2024 15:49:07 -0800 Subject: [PATCH 06/10] feat(typing): add possibly undefined check to mypy --- pyproject.toml | 51 +++++--------------------------------------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c6366d9f6c5b09..89c35655639480 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,10 @@ enable_error_code = ["ignore-without-code"] enable_error_code = ["possibly-undefined"] +# check for possibly unbound variables + +enable_error_code = ["possibly-undefined"] + [tool.django-stubs] django_settings_module = "sentry.conf.server_mypy" @@ -619,6 +623,7 @@ disable_error_code = [ "union-attr", "unreachable", "var-annotated", + "possibly-undefined", ] # end: sentry modules with typing issues @@ -653,49 +658,3 @@ module = [ disallow_any_generics = true disallow_untyped_defs = true # end: stronger typing - -# begin: sentry modules with possibly undefined variables -[[tool.mypy.overrides]] -module = [ - "sentry.api.endpoints.project_filter_details", - "sentry.api.endpoints.release_thresholds.release_threshold_status_index", - "sentry.api.endpoints.relocations.unpause", - "sentry.api.helpers.span_analysis", - "sentry.http", - "sentry.integrations.github.installation", - "sentry.integrations.slack.actions.notification", - "sentry.middleware.integrations.tasks", - "sentry.models.groupsubscription", - "sentry.nodestore.base", - "sentry.runner.commands.backup", - "sentry.runner.commands.cleanup", - "sentry.runner.commands.devservices", - "sentry.services.hybrid_cloud.import_export.impl", - "sentry.snuba.metrics_layer.query", - "sentry.snuba.metrics_performance", - "sentry.tasks.assemble", - "sentry.tasks.commit_context", - "sentry.tasks.post_process", - "sentry.utils.mockdata.core", - "tests.apidocs.endpoints.events.test_group_events", - "tests.apidocs.endpoints.events.test_group_issue_details", - "tests.sentry.api.endpoints.test_debug_files", - "tests.sentry.api.endpoints.test_project_rules", - "tests.sentry.integrations.bitbucket.test_issues", - "tests.sentry.integrations.github.test_issues", - "tests.sentry.issues.test_escalating", - "tests.sentry.models.test_groupsnooze", - "tests.sentry.replays.test_organization_replay_count", - "tests.sentry.rules.history.test_preview", - "tests.sentry.tasks.test_auto_ongoing_issues", - "tests.sentry.tasks.test_reprocessing2", - "tests.sentry.utils.test_event", - "tests.sentry.web.frontend.test_twofactor", - "tests.snuba.api.endpoints.test_organization_events", - "tests.snuba.api.endpoints.test_organization_events_stats", - "tests.snuba.api.endpoints.test_project_group_index", - "tests.snuba.tagstore.test_tagstore_backend", - "tests.snuba.tsdb.test_tsdb_backend", -] -# end: sentry modules with possibly undefined variables -disable_error_code = ["possibly-undefined"] From ea49f24920adba868c443481583d3081efa3b6b3 Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Thu, 22 Feb 2024 08:13:53 -0800 Subject: [PATCH 07/10] remove unrelated change, remove comment --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 89c35655639480..b1d43226eb9a73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,8 +68,6 @@ enable_error_code = ["ignore-without-code"] enable_error_code = ["possibly-undefined"] -# check for possibly unbound variables - enable_error_code = ["possibly-undefined"] [tool.django-stubs] From fa49fef91a9143fc7421e99d3e2a24be24b41cc8 Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:01:38 +0000 Subject: [PATCH 08/10] :knife: regenerate mypy module blocklist --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b1d43226eb9a73..ca6d3ff68fbc76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -621,7 +621,6 @@ disable_error_code = [ "union-attr", "unreachable", "var-annotated", - "possibly-undefined", ] # end: sentry modules with typing issues From 5fc38a63ac5d2cac1d6a476730731b350a05b89f Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Thu, 4 Apr 2024 11:28:25 -0700 Subject: [PATCH 09/10] feat(typing): add possibly undefined check for issues team code --- pyproject.toml | 16 +++++++++++++--- src/sentry/issues/grouptype.py | 1 + src/sentry/issues/ingest.py | 17 ++++++++--------- src/sentry/tasks/post_process.py | 1 + 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ca6d3ff68fbc76..2a9dd5c88e5293 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,9 +66,6 @@ warn_unused_ignores = true warn_redundant_casts = true enable_error_code = ["ignore-without-code"] -enable_error_code = ["possibly-undefined"] - -enable_error_code = ["possibly-undefined"] [tool.django-stubs] django_settings_module = "sentry.conf.server_mypy" @@ -655,3 +652,16 @@ module = [ disallow_any_generics = true disallow_untyped_defs = true # end: stronger typing + +# begin: possibly-undefined checks for issue team critical code +[[tool.mypy.overrides]] +module = [ + "sentry.issues.*", + "sentry.tasks.post_process", + "sentry.event_manager", + "sentry.grouping.*", + "sentry.tasks.store", + "sentry.ingest.consumer.processors" +] +enable_error_code = ["possibly-undefined"] +# end: possibly-undefined diff --git a/src/sentry/issues/grouptype.py b/src/sentry/issues/grouptype.py index 9ab9b7a6829d94..57f9d2f02e76e7 100644 --- a/src/sentry/issues/grouptype.py +++ b/src/sentry/issues/grouptype.py @@ -49,6 +49,7 @@ def add(self, group_type: type[GroupType]) -> None: raise ValueError( f"A group type with the type_id {group_type.type_id} has already been registered." ) + self._registry[group_type.type_id] = group_type self._slug_lookup[group_type.slug] = group_type self._category_lookup[group_type.category].add(group_type.type_id) diff --git a/src/sentry/issues/ingest.py b/src/sentry/issues/ingest.py index 81bcbd81bec360..fef28eac810b83 100644 --- a/src/sentry/issues/ingest.py +++ b/src/sentry/issues/ingest.py @@ -137,7 +137,6 @@ def materialize_metadata(occurrence: IssueOccurrence, event: Event) -> Occurrenc event_metadata["title"] = occurrence.issue_title event_metadata["value"] = occurrence.subtitle event_metadata["initial_priority"] = occurrence.initial_issue_priority - if occurrence.type == FeedbackGroup: # TODO: Should feedbacks be their own event type, so above call to event.get_event_medata # could populate this instead? @@ -199,14 +198,14 @@ def save_issue_from_occurrence( metrics.incr("issues.issue.dropped.rate_limiting") return None - with sentry_sdk.start_span( - op="issues.save_issue_from_occurrence.transaction" - ) as span, metrics.timer( - "issues.save_issue_from_occurrence.transaction", - tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id}, - sample_rate=1.0, - ) as metric_tags, transaction.atomic( - router.db_for_write(GroupHash) + with ( + sentry_sdk.start_span(op="issues.save_issue_from_occurrence.transaction") as span, + metrics.timer( + "issues.save_issue_from_occurrence.transaction", + tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id}, + sample_rate=1.0, + ) as metric_tags, + transaction.atomic(router.db_for_write(GroupHash)), ): group, is_new = _save_grouphash_and_group( project, event, new_grouphash, **cast(Mapping[str, Any], issue_kwargs) diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index 8812eab86375c7..f74f0ffc1e000e 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -1068,6 +1068,7 @@ def _get_replay_id(event): kafka_payload = transform_event_for_linking_payload(replay_id, group_event) except ValueError: metrics.incr("post_process.process_replay_link.id_invalid") + return publisher.publish( "ingest-replay-events", From a74be6e07c916d00cc02dc09e40aca5a888c63eb Mon Sep 17 00:00:00 2001 From: Joshua Ferge Date: Thu, 4 Apr 2024 11:32:43 -0700 Subject: [PATCH 10/10] remove stuff from old pr --- pyproject.toml | 8 ---- src/sentry/issues/grouptype.py | 1 - src/sentry/issues/ingest.py | 17 +++---- tools/mypy_helpers/make_module_ignores.py | 45 ------------------- .../mypy_without_ignore_possibly_undefined.py | 26 ----------- 5 files changed, 9 insertions(+), 88 deletions(-) delete mode 100644 tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py diff --git a/pyproject.toml b/pyproject.toml index 2a9dd5c88e5293..9ef18b78e283e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,6 @@ warn_unused_ignores = true warn_redundant_casts = true enable_error_code = ["ignore-without-code"] - [tool.django-stubs] django_settings_module = "sentry.conf.server_mypy" @@ -258,7 +257,6 @@ module = [ "sentry.auth.providers.saml2.views", "sentry.auth.system", "sentry.auth.view", - "sentry.buffer.redis", "sentry.db.mixin", "sentry.db.models.manager.base", "sentry.db.models.paranoia", @@ -407,7 +405,6 @@ module = [ "sentry.plugins.providers.repository", "sentry.profiles.task", "sentry.profiles.utils", - "sentry.quotas.redis", "sentry.receivers.releases", "sentry.receivers.sentry_apps", "sentry.release_health.metrics_sessions_v2", @@ -589,14 +586,10 @@ module = [ "tests.sentry.ingest.test_slicing", "tests.sentry.integrations.github.test_client", "tests.sentry.integrations.slack.test_requests", - "tests.sentry.issues.endpoints.test_group_events", - "tests.sentry.issues.endpoints.test_organization_group_index", "tests.sentry.issues.test_utils", "tests.sentry.models.test_organizationmember", "tests.sentry.replays.test_project_replay_recording_segment_index", - "tests.sentry.tasks.test_daily_summary", "tests.sentry.tasks.test_post_process", - "tools.mypy_helpers.make_module_ignores", ] disable_error_code = [ "arg-type", @@ -611,7 +604,6 @@ disable_error_code = [ "misc", "operator", "override", - "possibly-undefined", "return-value", "typeddict-item", "typeddict-unknown-key", diff --git a/src/sentry/issues/grouptype.py b/src/sentry/issues/grouptype.py index 57f9d2f02e76e7..9ab9b7a6829d94 100644 --- a/src/sentry/issues/grouptype.py +++ b/src/sentry/issues/grouptype.py @@ -49,7 +49,6 @@ def add(self, group_type: type[GroupType]) -> None: raise ValueError( f"A group type with the type_id {group_type.type_id} has already been registered." ) - self._registry[group_type.type_id] = group_type self._slug_lookup[group_type.slug] = group_type self._category_lookup[group_type.category].add(group_type.type_id) diff --git a/src/sentry/issues/ingest.py b/src/sentry/issues/ingest.py index fef28eac810b83..81bcbd81bec360 100644 --- a/src/sentry/issues/ingest.py +++ b/src/sentry/issues/ingest.py @@ -137,6 +137,7 @@ def materialize_metadata(occurrence: IssueOccurrence, event: Event) -> Occurrenc event_metadata["title"] = occurrence.issue_title event_metadata["value"] = occurrence.subtitle event_metadata["initial_priority"] = occurrence.initial_issue_priority + if occurrence.type == FeedbackGroup: # TODO: Should feedbacks be their own event type, so above call to event.get_event_medata # could populate this instead? @@ -198,14 +199,14 @@ def save_issue_from_occurrence( metrics.incr("issues.issue.dropped.rate_limiting") return None - with ( - sentry_sdk.start_span(op="issues.save_issue_from_occurrence.transaction") as span, - metrics.timer( - "issues.save_issue_from_occurrence.transaction", - tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id}, - sample_rate=1.0, - ) as metric_tags, - transaction.atomic(router.db_for_write(GroupHash)), + with sentry_sdk.start_span( + op="issues.save_issue_from_occurrence.transaction" + ) as span, metrics.timer( + "issues.save_issue_from_occurrence.transaction", + tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id}, + sample_rate=1.0, + ) as metric_tags, transaction.atomic( + router.db_for_write(GroupHash) ): group, is_new = _save_grouphash_and_group( project, event, new_grouphash, **cast(Mapping[str, Any], issue_kwargs) diff --git a/tools/mypy_helpers/make_module_ignores.py b/tools/mypy_helpers/make_module_ignores.py index 5e575286371f06..414f12080525c9 100644 --- a/tools/mypy_helpers/make_module_ignores.py +++ b/tools/mypy_helpers/make_module_ignores.py @@ -57,51 +57,6 @@ def main() -> int: with open("pyproject.toml", "w") as f: f.write(before + begin + generated + end + rest) - # # begin possibly_undefined fixer - shutil.rmtree(".mypy_cache", ignore_errors=True) - - codes = set() - filenames = set() - out = subprocess.run( - ( - sys.executable, - "-m", - "tools.mypy_helpers.mypy_without_ignore_possibly_undefined", - *sys.argv[1:], - ), - capture_output=True, - ) - for line in out.stdout.decode().splitlines(): - filename, _, _ = line.partition(":") - if filename.endswith(".py"): - filenames.add(filename) - if match is not None: - codes.add(match[1]) - - os.makedirs(".artifacts", exist_ok=True) - with open(".artifacts/mypy-all", "wb") as f: - f.write(out.stdout) - - mods = [] - for filename in sorted(filenames): - # TODO: removeprefix / removesuffix python 3.9+ - if filename.endswith(".py"): - filename = filename[: -len(".py")] - if filename.startswith("src/"): - filename = filename[len("src/") :] - if filename.endswith("/__init__"): - filename = filename[: -len("/__init__")] - mods.append(filename.replace("/", ".")) - mods_s = "".join(f' "{mod}",\n' for mod in mods) - generated = f"[[tool.mypy.overrides]]\n" f"module = [\n{mods_s}]\n" - with open("pyproject.toml") as f: - src = f.read() - msg = "sentry modules with possibly undefined variables" - before, begin, rest = src.partition(f"# begin: {msg}\n") - _, end, rest = rest.partition(f"# end: {msg}\n") - with open("pyproject.toml", "w") as f: - f.write(before + begin + generated + end + rest) - return 0 diff --git a/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py b/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py deleted file mode 100644 index fc7b15718135b4..00000000000000 --- a/tools/mypy_helpers/mypy_without_ignore_possibly_undefined.py +++ /dev/null @@ -1,26 +0,0 @@ -from __future__ import annotations - -import os.path -import subprocess -import sys -import tempfile - - -def main() -> int: - with open("pyproject.toml") as f: - src = f.read() - msg = "sentry modules with possibly undefined variables" - before, begin, rest = src.partition(f"# begin: {msg}\n") - _, end, rest = rest.partition(f"# end: {msg}\n") - - with tempfile.TemporaryDirectory() as tmpdir: - cfg = os.path.join(tmpdir, "mypy.toml") - print(before + begin + end + rest) - with open(cfg, "w") as f: - f.write(before + begin + end + rest) - - return subprocess.call(("mypy", "--config", cfg, *sys.argv[1:])) - - -if __name__ == "__main__": - raise SystemExit(main())