Browse Source

ref: upgrade mypy to 1.14.0 (#82575)

<!-- Describe your PR here. -->
anthony sottile 2 months ago
parent
commit
0d337eb5e2

+ 1 - 1
requirements-dev-frozen.txt

@@ -106,7 +106,7 @@ mmh3==4.0.0
 more-itertools==8.13.0
 msgpack==1.1.0
 msgpack-types==0.2.0
-mypy==1.13.0
+mypy==1.14.0
 mypy-extensions==1.0.0
 nodeenv==1.9.1
 oauthlib==3.1.0

+ 1 - 1
requirements-dev.txt

@@ -41,7 +41,7 @@ sentry-forked-django-stubs>=5.1.1.post1
 sentry-forked-djangorestframework-stubs>=3.15.2.post1
 lxml-stubs
 msgpack-types>=0.2.0
-mypy>=1.13
+mypy>=1.14
 types-beautifulsoup4
 types-cachetools
 types-jsonschema

+ 17 - 25
src/sentry/backup/dependencies.py

@@ -95,28 +95,23 @@ class NormalizedModelName:
 #
 # TODO(getsentry/team-ospo#190): We should find a better way to store this information than a magic
 # list in this file. We should probably make a field (or method?) on `BaseModel` instead.
-@unique
-class RelocationRootModels(Enum):
-    """
-    Record the "root" models for a given `RelocationScope`.
-    """
-
-    Excluded: list[NormalizedModelName] = []
-    User = [NormalizedModelName("sentry.user")]
-    Organization = [NormalizedModelName("sentry.organization")]
-    Config = [
-        NormalizedModelName("sentry.controloption"),
-        NormalizedModelName("sentry.option"),
-        NormalizedModelName("sentry.relay"),
-        NormalizedModelName("sentry.relayusage"),
-        NormalizedModelName("sentry.userrole"),
-    ]
+_ROOT_MODELS: tuple[NormalizedModelName, ...] = (
+    # RelocationScope.User
+    NormalizedModelName("sentry.user"),
+    # RelocationScope.Organization
+    NormalizedModelName("sentry.organization"),
+    # RelocationScope.Config
+    NormalizedModelName("sentry.controloption"),
+    NormalizedModelName("sentry.option"),
+    NormalizedModelName("sentry.relay"),
+    NormalizedModelName("sentry.relayusage"),
+    NormalizedModelName("sentry.userrole"),
+    # RelocationScope.Global
     # TODO(getsentry/team-ospo#188): Split out extension scope root models from this list.
-    Global = [
-        NormalizedModelName("sentry.apiapplication"),
-        NormalizedModelName("sentry.integration"),
-        NormalizedModelName("sentry.sentryapp"),
-    ]
+    NormalizedModelName("sentry.apiapplication"),
+    NormalizedModelName("sentry.integration"),
+    NormalizedModelName("sentry.sentryapp"),
+)
 
 
 @unique
@@ -542,10 +537,7 @@ def dependencies() -> dict[NormalizedModelName, ModelRelations]:
             )
 
     # Get a flat list of "root" models, then mark all of them as non-dangling.
-    relocation_root_models: list[NormalizedModelName] = []
-    for root_models in RelocationRootModels:
-        relocation_root_models.extend(root_models.value)
-    for model_name in relocation_root_models:
+    for model_name in _ROOT_MODELS:
         model_dependencies_dict[model_name].dangling = False
 
     # TODO(getsentry/team-ospo#190): In practice, we can treat `AlertRule`'s dependency on

+ 1 - 0
src/sentry/integrations/slack/webhooks/action.py

@@ -406,6 +406,7 @@ class SlackActionEndpoint(Endpoint):
                     )
 
                 view = View(**slack_request.data["view"])
+                assert view.private_metadata is not None
                 private_metadata = orjson.loads(view.private_metadata)
                 original_tags_from_request = set(private_metadata.get("tags", {}))
 

+ 1 - 4
src/sentry/notifications/utils/__init__.py

@@ -275,10 +275,7 @@ def has_integrations(organization: Organization, project: Project) -> bool:
 
 
 def is_alert_rule_integration(provider: IntegrationProvider) -> bool:
-    return any(
-        feature == (IntegrationFeatures.ALERT_RULE or IntegrationFeatures.ENTERPRISE_ALERT_RULE)
-        for feature in provider.features
-    )
+    return IntegrationFeatures.ALERT_RULE in provider.features
 
 
 def has_alert_integration(project: Project) -> bool:

+ 1 - 1
tools/mypy_helpers/plugin.py

@@ -122,7 +122,7 @@ class SentryMypyPlugin(Plugin):
 
     def get_base_class_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None:
         # XXX: this is a hack -- I don't know if there's a better callback to modify a class
-        if fullname == "io.BytesIO":
+        if fullname == "_io.BytesIO":
             return _adjust_http_request_members
         else:
             return None