Просмотр исходного кода

ref: upgrade sentry-relay to get typed support (#54287)

mypy diff:

```diff
--- /dev/fd/63	2023-08-07 12:22:06
+++ /dev/fd/62	2023-08-07 12:22:06
-Found 5664 errors in 985 files (checked 5035 source files)
+Found 5663 errors in 984 files (checked 5035 source files)
-src/sentry/utils/outcomes.py:73: error: Cannot use isinstance() with Any type  [misc]
```
anthony sottile 1 год назад
Родитель
Сommit
04a8125a03

+ 0 - 2
pyproject.toml

@@ -118,7 +118,6 @@ module = [
     "rb.*",
     "rediscluster.*",
     "requests_oauthlib.*",
-    "sentry_relay.*",
     "sqlparse.*",
     "statsd.*",
     "toronado.*",
@@ -808,7 +807,6 @@ module = [
     "sentry.utils.http",
     "sentry.utils.locking.backends.migration",
     "sentry.utils.metrics",
-    "sentry.utils.outcomes",
     "sentry.utils.performance_issues.detectors.io_main_thread_detector",
     "sentry.utils.performance_issues.detectors.mn_plus_one_db_span_detector",
     "sentry.utils.performance_issues.detectors.n_plus_one_api_calls_detector",

+ 1 - 1
requirements-base.txt

@@ -61,7 +61,7 @@ rfc3986-validator>=0.1.1
 sentry-arroyo>=2.14.1
 sentry-kafka-schemas>=0.1.22
 sentry-redis-tools>=0.1.7
-sentry-relay>=0.8.28
+sentry-relay>=0.8.29
 sentry-sdk>=1.28.1
 snuba-sdk>=1.0.5
 simplejson>=3.17.6

+ 1 - 1
requirements-dev-frozen.txt

@@ -172,7 +172,7 @@ sentry-arroyo==2.14.1
 sentry-cli==2.16.0
 sentry-kafka-schemas==0.1.22
 sentry-redis-tools==0.1.7
-sentry-relay==0.8.28
+sentry-relay==0.8.29
 sentry-sdk==1.28.1
 simplejson==3.17.6
 six==1.16.0

+ 1 - 1
requirements-frozen.txt

@@ -119,7 +119,7 @@ selenium==4.3.0
 sentry-arroyo==2.14.1
 sentry-kafka-schemas==0.1.22
 sentry-redis-tools==0.1.7
-sentry-relay==0.8.28
+sentry-relay==0.8.29
 sentry-sdk==1.28.1
 simplejson==3.17.6
 six==1.16.0

+ 1 - 1
src/sentry/api/authentication.py

@@ -11,7 +11,7 @@ from rest_framework.authentication import (
 )
 from rest_framework.exceptions import AuthenticationFailed
 from rest_framework.request import Request
-from sentry_relay import UnpackError
+from sentry_relay.exceptions import UnpackError
 
 from sentry import options
 from sentry.auth.system import SystemToken, is_internal_ip

+ 1 - 1
src/sentry/api/endpoints/data_scrubbing_selector_suggestions.py

@@ -2,7 +2,7 @@ from typing import Any, Dict
 
 from rest_framework.request import Request
 from rest_framework.response import Response
-from sentry_relay import pii_selector_suggestions_from_event
+from sentry_relay.processing import pii_selector_suggestions_from_event
 
 from sentry import nodestore
 from sentry.api.base import region_silo_endpoint

+ 1 - 1
src/sentry/api/endpoints/relay/register_challenge.py

@@ -2,7 +2,7 @@ from django.conf import settings
 from rest_framework import serializers, status
 from rest_framework.request import Request
 from rest_framework.response import Response
-from sentry_relay import create_register_challenge, is_version_supported
+from sentry_relay.auth import create_register_challenge, is_version_supported
 
 from sentry import options
 from sentry.api.authentication import is_internal_relay, is_static_relay, relay_from_id

+ 2 - 1
src/sentry/api/endpoints/relay/register_response.py

@@ -2,7 +2,8 @@ from django.utils import timezone
 from rest_framework import serializers, status
 from rest_framework.request import Request
 from rest_framework.response import Response
-from sentry_relay import UnpackErrorSignatureExpired, validate_register_response
+from sentry_relay.auth import validate_register_response
+from sentry_relay.exceptions import UnpackErrorSignatureExpired
 
 from sentry import options
 from sentry.api.authentication import is_internal_relay, relay_from_id

+ 1 - 1
src/sentry/api/serializers/models/event.py

@@ -7,7 +7,7 @@ from typing import Any, Dict, Sequence
 
 import sentry_sdk
 import sqlparse
-from sentry_relay import meta_with_chunks
+from sentry_relay.processing import meta_with_chunks
 
 from sentry.api.serializers import Serializer, register, serialize
 from sentry.api.serializers.models.release import GroupEventReleaseSerializer

+ 4 - 4
src/sentry/constants.py

@@ -9,10 +9,10 @@ from collections import namedtuple
 from datetime import timedelta
 from typing import Dict, List, Optional, Sequence, Tuple, cast
 
-import sentry_relay
+import sentry_relay.consts
+import sentry_relay.processing
 from django.conf import settings
 from django.utils.translation import gettext_lazy as _
-from typing_extensions import TypeAlias
 
 from sentry.utils.geo import rust_geoip
 from sentry.utils.integrationdocs import load_doc
@@ -302,7 +302,7 @@ SENTRY_APP_ACTIONS = frozenset(
 HTTP_METHODS = ("GET", "POST", "PUT", "OPTIONS", "HEAD", "DELETE", "TRACE", "CONNECT", "PATCH")
 
 # See https://github.com/getsentry/relay/blob/master/relay-general/src/protocol/constants.rs
-VALID_PLATFORMS = sentry_relay.VALID_PLATFORMS
+VALID_PLATFORMS = sentry_relay.processing.VALID_PLATFORMS
 
 OK_PLUGIN_ENABLED = _("The {name} integration has been enabled.")
 
@@ -639,7 +639,7 @@ EVENTS_MEMBER_ADMIN_DEFAULT = True
 ALERTS_MEMBER_WRITE_DEFAULT = True
 
 # Defined at https://github.com/getsentry/relay/blob/master/relay-common/src/constants.rs
-DataCategory: TypeAlias = sentry_relay.DataCategory
+DataCategory = sentry_relay.consts.DataCategory
 
 CRASH_RATE_ALERT_SESSION_COUNT_ALIAS = "_total_count"
 CRASH_RATE_ALERT_AGGREGATE_ALIAS = "_crash_rate_alert_aggregate"

Некоторые файлы не были показаны из-за большого количества измененных файлов