Skip to content

Commit 89cf46b

Browse files
Revert "Reapply "ref: enable local_partial_types=True (#89854)" (#90001)"
This reverts commit c757c35. Co-authored-by: GabeVillalobos <5643012+GabeVillalobos@users.noreply.github.com>
1 parent ec521cd commit 89cf46b

File tree

22 files changed

+193
-146
lines changed

22 files changed

+193
-146
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ warn_unused_configs = true
6262
warn_unused_ignores = true
6363
warn_redundant_casts = true
6464
enable_error_code = ["ignore-without-code", "redundant-self"]
65-
local_partial_types = true # compat with dmypy
6665

6766
[tool.django-stubs]
6867
django_settings_module = "sentry.conf.server_mypy"

src/sentry/api/endpoints/organization_details.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
REQUIRE_SCRUB_DEFAULTS_DEFAULT,
5858
REQUIRE_SCRUB_IP_ADDRESS_DEFAULT,
5959
ROLLBACK_ENABLED_DEFAULT,
60+
SAFE_FIELDS_DEFAULT,
6061
SAMPLING_MODE_DEFAULT,
6162
SCRAPE_JAVASCRIPT_DEFAULT,
63+
SENSITIVE_FIELDS_DEFAULT,
6264
TARGET_SAMPLE_RATE_DEFAULT,
6365
ObjectStatus,
6466
)
@@ -122,8 +124,8 @@
122124
ACCOUNT_RATE_LIMIT_DEFAULT,
123125
),
124126
("dataScrubber", "sentry:require_scrub_data", bool, REQUIRE_SCRUB_DATA_DEFAULT),
125-
("sensitiveFields", "sentry:sensitive_fields", list, None),
126-
("safeFields", "sentry:safe_fields", list, None),
127+
("sensitiveFields", "sentry:sensitive_fields", list, SENSITIVE_FIELDS_DEFAULT),
128+
("safeFields", "sentry:safe_fields", list, SAFE_FIELDS_DEFAULT),
127129
(
128130
"scrapeJavaScript",
129131
"sentry:scrape_javascript",

src/sentry/api/serializers/models/organization.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@
4646
REQUIRE_SCRUB_IP_ADDRESS_DEFAULT,
4747
RESERVED_ORGANIZATION_SLUGS,
4848
ROLLBACK_ENABLED_DEFAULT,
49+
SAFE_FIELDS_DEFAULT,
4950
SAMPLING_MODE_DEFAULT,
5051
SCRAPE_JAVASCRIPT_DEFAULT,
52+
SENSITIVE_FIELDS_DEFAULT,
53+
STREAMLINE_UI_ONLY,
5154
TARGET_SAMPLE_RATE_DEFAULT,
5255
ObjectStatus,
5356
)
@@ -642,8 +645,9 @@ def serialize( # type: ignore[explicit-override, override]
642645
"dataScrubberDefaults": bool(
643646
obj.get_option("sentry:require_scrub_defaults", REQUIRE_SCRUB_DEFAULTS_DEFAULT)
644647
),
645-
"sensitiveFields": obj.get_option("sentry:sensitive_fields", None) or [],
646-
"safeFields": obj.get_option("sentry:safe_fields", None) or [],
648+
"sensitiveFields": obj.get_option("sentry:sensitive_fields", SENSITIVE_FIELDS_DEFAULT)
649+
or [],
650+
"safeFields": obj.get_option("sentry:safe_fields", SAFE_FIELDS_DEFAULT) or [],
647651
"storeCrashReports": convert_crashreport_count(
648652
obj.get_option("sentry:store_crash_reports")
649653
),
@@ -695,7 +699,7 @@ def serialize( # type: ignore[explicit-override, override]
695699
"rollbackEnabled": bool(
696700
obj.get_option("sentry:rollback_enabled", ROLLBACK_ENABLED_DEFAULT)
697701
),
698-
"streamlineOnly": obj.get_option("sentry:streamline_ui_only", None),
702+
"streamlineOnly": obj.get_option("sentry:streamline_ui_only", STREAMLINE_UI_ONLY),
699703
"trustedRelays": [
700704
# serialize trusted relays info into their external form
701705
_relay_internal_to_external(raw)

src/sentry/auth/authenticators/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
from __future__ import annotations
2-
3-
from typing import TYPE_CHECKING
4-
5-
from .base import AuthenticatorInterface
1+
from .base import AuthenticatorInterface # NOQA
62
from .recovery_code import RecoveryCodeInterface
73
from .sms import SmsInterface
84
from .totp import TotpInterface
95
from .u2f import U2fInterface
106

11-
if TYPE_CHECKING:
12-
from django.utils.functional import _StrPromise
13-
14-
AUTHENTICATOR_INTERFACES: dict[str, type[AuthenticatorInterface]] = {}
15-
AUTHENTICATOR_INTERFACES_BY_TYPE: dict[int, type[AuthenticatorInterface]] = {}
16-
AUTHENTICATOR_CHOICES: list[tuple[int, str | _StrPromise]] = []
7+
AUTHENTICATOR_INTERFACES = {}
8+
AUTHENTICATOR_INTERFACES_BY_TYPE = {}
9+
AUTHENTICATOR_CHOICES = []
1710

1811

1912
def register_authenticator(cls: type[AuthenticatorInterface]) -> None:

src/sentry/auth/providers/oauth2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def _get_redirect_url() -> str:
2626

2727

2828
class OAuth2Login(AuthView):
29-
authorize_url: str | None = None
30-
client_id: str | None = None
29+
authorize_url = None
30+
client_id = None
3131
scope = ""
3232

3333
def __init__(self, authorize_url=None, client_id=None, scope=None, *args, **kwargs):
@@ -71,9 +71,9 @@ def dispatch(self, request: HttpRequest, helper) -> HttpResponse:
7171

7272

7373
class OAuth2Callback(AuthView):
74-
access_token_url: str | None = None
75-
client_id: str | None = None
76-
client_secret: str | None = None
74+
access_token_url = None
75+
client_id = None
76+
client_secret = None
7777

7878
def __init__(self, access_token_url=None, client_id=None, client_secret=None, *args, **kwargs):
7979
super().__init__(*args, **kwargs)

src/sentry/auth/system.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class SystemToken:
4444

4545
id = "<system>"
4646
token = "<system.secret-key>"
47-
application: None = None
48-
organization_id: None = None
49-
scoping_organization_id: None = None
47+
application = None
48+
organization_id = None
49+
scoping_organization_id = None
5050

5151
@classmethod
5252
def from_request(cls, request: HttpRequest, token: str) -> SystemToken | None:

src/sentry/conf/server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import tempfile
1313
from collections.abc import Callable, Mapping, MutableSequence
1414
from datetime import datetime, timedelta
15-
from typing import Any, Final, Literal, Union, overload
15+
from typing import Any, Final, Union, overload
1616
from urllib.parse import urlparse
1717

1818
import sentry
@@ -359,7 +359,7 @@ def env(
359359
# Once relay's fully rolled out, that can be deleted.
360360
# Until then, the safest and easiest thing to do is to disable this check
361361
# to leave things the way they were with Django <1.9.
362-
DATA_UPLOAD_MAX_MEMORY_SIZE: int | None = None
362+
DATA_UPLOAD_MAX_MEMORY_SIZE = None
363363

364364
TEMPLATES = [
365365
{
@@ -616,7 +616,7 @@ def env(
616616
# this breaks certain IDP flows where we need cookies sent to us on a redirected POST
617617
# request, and `Lax` doesnt permit this.
618618
# See here: https://docs.djangoproject.com/en/2.1/ref/settings/#session-cookie-samesite
619-
SESSION_COOKIE_SAMESITE: Literal["Strict", "Lax", None] = None
619+
SESSION_COOKIE_SAMESITE = None
620620

621621
BITBUCKET_CONSUMER_KEY = ""
622622
BITBUCKET_CONSUMER_SECRET = ""
@@ -747,7 +747,7 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
747747
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
748748
CELERY_IGNORE_RESULT = True
749749
CELERY_SEND_EVENTS = False
750-
CELERY_RESULT_BACKEND: str | None = None
750+
CELERY_RESULT_BACKEND = None
751751
CELERY_TASK_RESULT_EXPIRES = 1
752752
CELERY_DISABLE_RATE_LIMITS = True
753753
CELERY_DEFAULT_QUEUE = "default"
@@ -3215,6 +3215,9 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
32153215
# Similarity-v1: uses hardcoded set of event properties for diffing
32163216
SENTRY_SIMILARITY_INDEX_REDIS_CLUSTER = "default"
32173217

3218+
# Unused legacy option, there to satisfy getsentry CI. Remove from getsentry, then here
3219+
SENTRY_SIMILARITY2_INDEX_REDIS_CLUSTER = None
3220+
32183221
# How long the migration phase for grouping lasts
32193222
SENTRY_GROUPING_UPDATE_MIGRATION_PHASE = 30 * 24 * 3600 # 30 days
32203223

@@ -3277,7 +3280,7 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
32773280
# Zero Downtime Migrations settings as defined at
32783281
# https://github.com/tbicr/django-pg-zero-downtime-migrations#settings
32793282
ZERO_DOWNTIME_MIGRATIONS_RAISE_FOR_UNSAFE = True
3280-
ZERO_DOWNTIME_MIGRATIONS_LOCK_TIMEOUT: str | None = None
3283+
ZERO_DOWNTIME_MIGRATIONS_LOCK_TIMEOUT = None
32813284
ZERO_DOWNTIME_MIGRATIONS_STATEMENT_TIMEOUT: str | None = None
32823285
ZERO_DOWNTIME_MIGRATIONS_LOCK_TIMEOUT_FORCE = False
32833286
ZERO_DOWNTIME_MIGRATIONS_IDEMPOTENT_SQL = False
@@ -3410,7 +3413,7 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
34103413
SENTRY_PROFILE_CHUNKS_FUTURES_MAX_LIMIT = 10000
34113414

34123415
# How long we should wait for a gateway proxy request to return before giving up
3413-
GATEWAY_PROXY_TIMEOUT: int | None = None
3416+
GATEWAY_PROXY_TIMEOUT = None
34143417

34153418
SENTRY_SLICING_LOGICAL_PARTITION_COUNT = 256
34163419
# This maps a Sliceable for slicing by name and (lower logical partition, upper physical partition)

src/sentry/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,14 @@ class InsightModules(Enum):
691691
ACCOUNT_RATE_LIMIT_DEFAULT = 0
692692
REQUIRE_SCRUB_DATA_DEFAULT = False
693693
REQUIRE_SCRUB_DEFAULTS_DEFAULT = False
694+
SENSITIVE_FIELDS_DEFAULT = None
695+
SAFE_FIELDS_DEFAULT = None
694696
ATTACHMENTS_ROLE_DEFAULT = settings.SENTRY_DEFAULT_ROLE
695697
DEBUG_FILES_ROLE_DEFAULT = "admin"
696698
EVENTS_ADMIN_ROLE_DEFAULT = settings.SENTRY_DEFAULT_ROLE
697699
REQUIRE_SCRUB_IP_ADDRESS_DEFAULT = False
698700
SCRAPE_JAVASCRIPT_DEFAULT = True
701+
TRUSTED_RELAYS_DEFAULT = None
699702
JOIN_REQUESTS_DEFAULT = True
700703
HIDE_AI_FEATURES_DEFAULT = False
701704
GITHUB_COMMENT_BOT_DEFAULT = True
@@ -706,6 +709,7 @@ class InsightModules(Enum):
706709
TARGET_SAMPLE_RATE_DEFAULT = 1.0
707710
SAMPLING_MODE_DEFAULT = "organization"
708711
ROLLBACK_ENABLED_DEFAULT = True
712+
STREAMLINE_UI_ONLY = None
709713

710714
# `sentry:events_member_admin` - controls whether the 'member' role gets the event:admin scope
711715
EVENTS_MEMBER_ADMIN_DEFAULT = True

src/sentry/deletions/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080

8181
from __future__ import annotations
8282

83-
import functools
8483
from typing import TYPE_CHECKING, Any
8584

8685
if TYPE_CHECKING:
@@ -194,7 +193,9 @@ def load_defaults(manager: DeletionTaskManager) -> None:
194193
# fmt: on
195194

196195

197-
@functools.cache
196+
_default_manager = None
197+
198+
198199
def get_manager() -> DeletionTaskManager:
199200
"""
200201
Get the deletions default_manager
@@ -204,10 +205,13 @@ def get_manager() -> DeletionTaskManager:
204205
"""
205206
from sentry.deletions.base import ModelDeletionTask
206207

207-
default_manager = DeletionTaskManager(default_task=ModelDeletionTask)
208-
load_defaults(default_manager)
208+
global _default_manager
209+
210+
if _default_manager is None:
211+
_default_manager = DeletionTaskManager(default_task=ModelDeletionTask)
212+
load_defaults(_default_manager)
209213

210-
return default_manager
214+
return _default_manager
211215

212216

213217
def get(

src/sentry/filestore/gcs.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,22 @@ def _try_upload():
226226

227227

228228
class GoogleCloudStorage(Storage):
229-
def __init__(
230-
self,
231-
project_id=None,
232-
credentials=None,
233-
bucket_name=None,
234-
file_name_charset="utf-8",
235-
file_overwrite=True,
236-
download_url="https://www.googleapis.com",
237-
# The max amount of memory a returned file can take up before being
238-
# rolled over into a temporary file on disk. Default is 0: Do not roll over.
239-
max_memory_size=0,
240-
):
241-
self.project_id = project_id
242-
self.credentials = credentials
243-
self.bucket_name = bucket_name
244-
self.file_name_charset = file_name_charset
245-
self.file_overwrite = file_overwrite
246-
self.download_url = download_url
247-
self.max_memory_size = max_memory_size
229+
project_id = None
230+
credentials = None
231+
bucket_name = None
232+
file_name_charset = "utf-8"
233+
file_overwrite = True
234+
download_url = "https://www.googleapis.com"
235+
# The max amount of memory a returned file can take up before being
236+
# rolled over into a temporary file on disk. Default is 0: Do not roll over.
237+
max_memory_size = 0
238+
239+
def __init__(self, **settings):
240+
# check if some of the settings we've provided as class attributes
241+
# need to be overwritten with values passed in here
242+
for name, value in settings.items():
243+
if hasattr(self, name):
244+
setattr(self, name, value)
248245

249246
self._bucket = None
250247
self._client = None

src/sentry/filestore/s3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,28 @@ class S3Boto3Storage(Storage):
255255
connection_response_error = ClientError
256256
file_class = S3Boto3StorageFile
257257
# If config provided in init, signature_version and addressing_style settings/args are ignored.
258-
config: Config | None = None
258+
config = None
259259

260260
# used for looking up the access and secret key from env vars
261261
access_key_names = ["AWS_S3_ACCESS_KEY_ID", "AWS_ACCESS_KEY_ID"]
262262
secret_key_names = ["AWS_S3_SECRET_ACCESS_KEY", "AWS_SECRET_ACCESS_KEY"]
263263

264-
access_key: str | None = None
265-
secret_key: str | None = None
264+
access_key = None
265+
secret_key = None
266266
file_overwrite = True
267267
object_parameters: dict[str, str] = {}
268-
bucket_name: str | None = None
268+
bucket_name = None
269269
auto_create_bucket = False
270270
default_acl = "public-read"
271271
bucket_acl = default_acl
272272
querystring_auth = True
273273
querystring_expire = 3600
274-
signature_version: str | None = None
274+
signature_version = None
275275
reduced_redundancy = False
276276
location = ""
277277
encryption = False
278278
custom_domain: str | None = None
279-
addressing_style: str | None = None
279+
addressing_style = None
280280
secure_urls = True
281281
file_name_charset = "utf-8"
282282
gzip = False
@@ -289,8 +289,8 @@ class S3Boto3Storage(Storage):
289289
"image/svg+xml",
290290
)
291291
url_protocol = "https:"
292-
endpoint_url: str | None = None
293-
region_name: str | None = None
292+
endpoint_url = None
293+
region_name = None
294294
use_ssl = True
295295

296296
def __init__(self, acl=None, bucket=None, **settings):

src/sentry/identity/oauth2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def record_event(event: IntegrationPipelineViewType, provider: str):
244244

245245

246246
class OAuth2LoginView(PipelineView):
247-
authorize_url: str | None = None
248-
client_id: str | None = None
247+
authorize_url = None
248+
client_id = None
249249
scope = ""
250250

251251
def __init__(self, authorize_url=None, client_id=None, scope=None, *args, **kwargs):
@@ -294,9 +294,9 @@ def dispatch(self, request: HttpRequest, pipeline: Pipeline) -> HttpResponseBase
294294

295295

296296
class OAuth2CallbackView(PipelineView):
297-
access_token_url: str | None = None
298-
client_id: str | None = None
299-
client_secret: str | None = None
297+
access_token_url = None
298+
client_id = None
299+
client_secret = None
300300

301301
def __init__(self, access_token_url=None, client_id=None, client_secret=None, *args, **kwargs):
302302
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)