Browse Source

chore(hc): Enable stronger typing for a few hybridcloud modules (#70777)

`sentry.hybridcloud.*` and `sentry.services.hybrid_cloud.*` aren't quite
passing but we can enable these which already are in the mean time.
Matt Duncan 10 months ago
parent
commit
7c08bcb3d9

+ 31 - 0
pyproject.toml

@@ -558,6 +558,10 @@ module = [
     "sentry.buffer.redis",
     "sentry.build.*",
     "sentry.eventstore.reprocessing.redis",
+    "sentry.hybridcloud",
+    "sentry.hybridcloud.migrations.*",
+    "sentry.hybridcloud.options",
+    "sentry.hybridcloud.rpc_services.*",
     "sentry.issues",
     "sentry.issues.analytics",
     "sentry.issues.apps",
@@ -602,6 +606,32 @@ module = [
     "sentry.relay.config.metric_extraction",
     "sentry.reprocessing2",
     "sentry.runner.*",
+    "sentry.services.hybrid_cloud.access.*",
+    "sentry.services.hybrid_cloud.app.*",
+    "sentry.services.hybrid_cloud.hook.*",
+    "sentry.services.hybrid_cloud.identity.*",
+    "sentry.services.hybrid_cloud.integration.*",
+    "sentry.services.hybrid_cloud.issue.*",
+    "sentry.services.hybrid_cloud.log.*",
+    "sentry.services.hybrid_cloud.lost_password_hash.*",
+    "sentry.services.hybrid_cloud.notifications.*",
+    "sentry.services.hybrid_cloud.organization_actions.*",
+    "sentry.services.hybrid_cloud.organization_mapping.*",
+    "sentry.services.hybrid_cloud.organization_provisioning.*",
+    "sentry.services.hybrid_cloud.organizationmember_mapping.*",
+    "sentry.services.hybrid_cloud.orgauthtoken.*",
+    "sentry.services.hybrid_cloud.pagination",
+    "sentry.services.hybrid_cloud.project.*",
+    "sentry.services.hybrid_cloud.project_key.*",
+    "sentry.services.hybrid_cloud.region",
+    "sentry.services.hybrid_cloud.replica.*",
+    "sentry.services.hybrid_cloud.repository.*",
+    "sentry.services.hybrid_cloud.rpcmetrics",
+    "sentry.services.hybrid_cloud.sig",
+    "sentry.services.hybrid_cloud.tombstone.*",
+    "sentry.services.hybrid_cloud.user.*",
+    "sentry.services.hybrid_cloud.user_option.*",
+    "sentry.services.hybrid_cloud.util",
     "sentry.snuba.metrics.extraction",
     "sentry.tasks.commit_context",
     "sentry.tasks.on_demand_metrics",
@@ -667,6 +697,7 @@ module = [
     "tests.sentry.issues.test_status_change_consumer",
     "tests.sentry.issues.test_update_inbox",
     "tests.sentry.relay.config.test_metric_extraction",
+    "tests.sentry.services.hybrid_cloud.*",
     "tests.sentry.tasks.test_on_demand_metrics",
     "tools.*",
 ]

+ 2 - 2
src/sentry/hybridcloud/rpc_services/control_organization_provisioning/impl.py

@@ -35,7 +35,7 @@ class SlugMismatchException(Exception):
 
 def create_post_provision_outbox(
     provisioning_options: OrganizationProvisioningOptions, org_id: int
-):
+) -> RegionOutbox:
     return RegionOutbox(
         shard_scope=OutboxScope.ORGANIZATION_SCOPE,
         shard_identifier=org_id,
@@ -49,7 +49,7 @@ def create_organization_provisioning_outbox(
     organization_id: int,
     region_name: str,
     org_provision_payload: OrganizationProvisioningOptions | None,
-):
+) -> ControlOutbox:
     payload = org_provision_payload.json() if org_provision_payload is not None else None
     return ControlOutbox(
         region_name=region_name,

+ 1 - 1
src/sentry/hybridcloud/rpc_services/region_organization_provisioning/impl.py

@@ -20,7 +20,7 @@ from sentry.services.organization import OrganizationProvisioningOptions
 
 def create_post_provision_outbox(
     provisioning_options: OrganizationProvisioningOptions, org_id: int
-):
+) -> RegionOutbox:
     return RegionOutbox(
         shard_scope=OutboxScope.ORGANIZATION_SCOPE,
         shard_identifier=org_id,

+ 1 - 1
src/sentry/services/hybrid_cloud/app/impl.py

@@ -271,7 +271,7 @@ class DatabaseBackedAppService(AppService):
         organization_id: int,
         integration_name: str,
         integration_scopes: list[str],
-        integration_creator_id,
+        integration_creator_id: int,
         metadata: dict[str, Any] | None = None,
     ) -> RpcSentryAppInstallation:
         admin_user = User.objects.get(id=integration_creator_id)

+ 1 - 1
src/sentry/services/hybrid_cloud/notifications/impl.py

@@ -64,7 +64,7 @@ class DatabaseBackedNotificationsService(NotificationsService):
         scope_type: NotificationScopeEnum,
         scope_identifier: int,
         value: NotificationSettingsOptionEnum,
-    ):
+    ) -> None:
         kwargs = {}
         if actor.is_user:
             kwargs["user_id"] = actor.id

+ 1 - 1
src/sentry/services/hybrid_cloud/organization_mapping/impl.py

@@ -86,7 +86,7 @@ class DatabaseBackedOrganizationMappingService(OrganizationMappingService):
 
     def _upsert_organization_slug_reservation_for_monolith(
         self, organization_id: int, mapping_update: RpcOrganizationMappingUpdate
-    ):
+    ) -> None:
         org_slug_reservation_qs = OrganizationSlugReservation.objects.filter(
             organization_id=organization_id
         )

+ 1 - 1
src/sentry/services/hybrid_cloud/project_key/model.py

@@ -31,5 +31,5 @@ class RpcProjectKey(RpcModel):
     status: int = ProjectKeyStatus.INACTIVE
 
     @property
-    def is_active(self):
+    def is_active(self) -> bool:
         return self.status == ProjectKeyStatus.ACTIVE

+ 1 - 1
src/sentry/services/hybrid_cloud/replica/impl.py

@@ -123,7 +123,7 @@ def handle_replication(
     source_model: type[ReplicatedControlModel] | type[ReplicatedRegionModel],
     destination: BaseModel,
     fk: str | None = None,
-):
+) -> None:
     category: OutboxCategory = source_model.category
     destination_model: type[BaseModel] = type(destination)
     fk = fk or get_foreign_key_column(destination, source_model)

+ 1 - 1
src/sentry/services/hybrid_cloud/rpc.py

@@ -580,7 +580,7 @@ class _RemoteSiloCall:
         except requests.exceptions.Timeout as e:
             raise self._remote_exception(f"Timeout of {settings.RPC_TIMEOUT} exceeded") from e
 
-    def _check_disabled(self):
+    def _check_disabled(self) -> None:
         if disabled_service_methods := options.get("hybrid_cloud.rpc.disabled-service-methods"):
             service_method = f"{self.service_name}.{self.method_name}"
             if service_method in disabled_service_methods:

+ 1 - 1
src/sentry/services/hybrid_cloud/rpcmetrics.py

@@ -52,7 +52,7 @@ class RpcMetricTracker:
             new_tracker = _LOCAL_TRACKER.tracker = cls()
             return new_tracker
 
-    def save_record(self, record: RpcMetricRecord):
+    def save_record(self, record: RpcMetricRecord) -> None:
         for span in self.spans:
             span.records.append(record)
 

Some files were not shown because too many files changed in this diff