Skip to content

Commit 2136ed2

Browse files
ref: upgrade django-stubs to 5.0.0 (#70433)
here's the diff in ignored errors as well: ```diff $ diff -u <(sort .artifacts/mypy-all | sed -r 's/\.py:[0-9]+:/.py:###:/g') <(sort .artifacts/mypy-all.new | sed -r 's/\.py:[0-9]+:/.py:###:/g') --- /dev/fd/63 2024-05-07 13:10:14 +++ /dev/fd/62 2024-05-07 13:10:14 @@ -1,11 +1,11 @@ -.venv/lib/python3.11/site-packages/django-stubs/forms/forms.pyi:38: note: "Form" defined here +.venv/lib/python3.11/site-packages/django-stubs/forms/forms.pyi:36: note: "Form" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/builtins.pyi:466: note: "replace" of "str" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/builtins.pyi:466: note: "replace" of "str" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/typing.pyi:902: note: "update" of "TypedDict" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/typing.pyi:902: note: "update" of "TypedDict" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/typing.pyi:902: note: "update" of "TypedDict" defined here .venv/lib/python3.11/site-packages/mypy/typeshed/stdlib/typing.pyi:902: note: "update" of "TypedDict" defined here -Found 3095 errors in 420 files (checked 5695 source files) +Found 3091 errors in 418 files (checked 5695 source files) src/sentry/api/base.py:###: error: "Request" has no attribute "json_body" [attr-defined] src/sentry/api/base.py:###: error: "Request" has no attribute "json_body" [attr-defined] src/sentry/api/base.py:###: error: Statement is unreachable [unreachable] @@ -2633,7 +2633,7 @@ src/sentry/plugins/bases/issue2.py:###: note: def needs_auth(self, user: Any, **kwargs: Any) -> Any src/sentry/plugins/bases/issue2.py:###: note: Subclass: src/sentry/plugins/bases/issue2.py:###: note: Superclass: -src/sentry/plugins/bases/issue2.py:###: error: Incompatible types in assignment (expression has type "dict[str, Any]", target has type "Sequence[str]") [assignment] +src/sentry/plugins/bases/issue2.py:###: error: Incompatible types in assignment (expression has type "dict[str, Any]", target has type "Sequence[str] | _StrPromise") [assignment] src/sentry/plugins/bases/issue2.py:###: error: No overload variant of "getattr" matches argument types "None", "None" [call-overload] src/sentry/plugins/bases/issue2.py:###: note: def [_T] getattr(object, str, _T, /) -> Any | _T src/sentry/plugins/bases/issue2.py:###: note: def getattr(object, str, /) -> Any @@ -3178,7 +3178,6 @@ src/sentry/sentry_apps/installations.py:###: error: Item "None" of "User | None" has no attribute "id" [union-attr] src/sentry/sentry_apps/installations.py:###: error: Incompatible return value type (got "ApiApplication | None", expected "ApiApplication") [return-value] src/sentry/sentry_apps/installations.py:###: error: Item "None" of "ApiApplication | None" has no attribute "id" [union-attr] -src/sentry/sentry_metrics/configuration.py:###: error: Import cycle from Django settings module prevents type inference for 'SENTRY_METRICS_INDEXER_WRITES_LIMITER_OPTIONS_PERFORMANCE' [misc] src/sentry/sentry_metrics/consumers/indexer/slicing_router.py:###: error: Argument "sliceable" to "SlicingRouter" has incompatible type "str"; expected "Literal['generic_metrics']" [arg-type] src/sentry/sentry_metrics/indexer/postgres/postgres_v2.py:###: error: Unexpected attribute "use_case_id" for model "BaseIndexer" [misc] src/sentry/shared_integrations/client/base.py:###: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc] @@ -3740,9 +3739,6 @@ src/sentry/web/frontend/disabled_member_view.py:###: note: def handle(self, request: Request, organization: Any, **kwargs: Any) -> HttpResponse src/sentry/web/frontend/disabled_member_view.py:###: note: Subclass: src/sentry/web/frontend/disabled_member_view.py:###: note: Superclass: -src/sentry/web/frontend/generic.py:###: error: Import cycle from Django settings module prevents type inference for 'DEBUG' [misc] -src/sentry/web/frontend/generic.py:###: error: Import cycle from Django settings module prevents type inference for 'DEBUG' [misc] -src/sentry/web/frontend/generic.py:###: error: Import cycle from Django settings module prevents type inference for 'DEBUG' [misc] src/sentry/web/frontend/group_plugin_action.py:###: error: Signature of "handle" incompatible with supertype "BaseView" [override] src/sentry/web/frontend/group_plugin_action.py:###: note: def handle(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase src/sentry/web/frontend/group_plugin_action.py:###: note: def handle(self, request: Request, organization: Any, project: Any, group_id: Any, slug: Any) -> Response ``` <!-- Describe your PR here. -->
1 parent c13fbca commit 2136ed2

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ module = [
425425
"sentry.search.utils",
426426
"sentry.sentry_apps.apps",
427427
"sentry.sentry_apps.installations",
428-
"sentry.sentry_metrics.configuration",
429428
"sentry.sentry_metrics.consumers.indexer.slicing_router",
430429
"sentry.sentry_metrics.indexer.postgres.postgres_v2",
431430
"sentry.shared_integrations.client.base",
@@ -495,7 +494,6 @@ module = [
495494
"sentry.web.frontend.debug.debug_organization_invite_request",
496495
"sentry.web.frontend.debug.debug_organization_join_request",
497496
"sentry.web.frontend.disabled_member_view",
498-
"sentry.web.frontend.generic",
499497
"sentry.web.frontend.group_plugin_action",
500498
"sentry.web.frontend.idp_email_verification",
501499
"sentry.web.frontend.integration_extension_configuration",

requirements-dev-frozen.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ django==5.0.4
4343
django-crispy-forms==1.14.0
4444
django-csp==3.8
4545
django-pg-zero-downtime-migrations==0.13
46-
django-stubs-ext==4.2.7
46+
django-stubs-ext==5.0.0
4747
djangorestframework==3.15.1
4848
docker==6.1.3
4949
drf-spectacular==0.26.3
@@ -178,7 +178,7 @@ selenium==4.16.0
178178
sentry-arroyo==2.16.5
179179
sentry-cli==2.16.0
180180
sentry-devenv==1.6.2
181-
sentry-forked-django-stubs==4.2.7.post3
181+
sentry-forked-django-stubs==5.0.0.post3
182182
sentry-forked-djangorestframework-stubs==3.14.5.post1
183183
sentry-kafka-schemas==0.1.79
184184
sentry-ophio==0.2.7

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pip-tools>=7.1.0
3434
packaging>=21.3
3535

3636
# for type checking
37-
sentry-forked-django-stubs>=4.2.7.post3
37+
sentry-forked-django-stubs>=5.0.0.post3
3838
sentry-forked-djangorestframework-stubs>=3.14.5.post1
3939
lxml-stubs
4040
msgpack-types>=0.2.0

src/sentry/silo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __str__(self) -> str:
4040
def get_current_mode(cls) -> SiloMode:
4141
from django.conf import settings
4242

43-
configured_mode: str | SiloMode | None = settings.SILO_MODE # type: ignore[misc]
43+
configured_mode = settings.SILO_MODE
4444
process_level_silo_mode = cls.resolve(configured_mode)
4545
return SingleProcessSiloModeState.get_mode() or process_level_silo_mode
4646

src/sentry/utils/email/signer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
2626
super().__init__(*args, **kwargs)
2727

2828
def signature(self, value: str | bytes, key: str | bytes | None = None) -> str:
29-
return super().signature(value, key=key).lower() # type: ignore[call-arg] # fixed in django-stubs 5.0
29+
return super().signature(value, key=key).lower()
3030

3131
def unsign(self, signed_value: str) -> str:
3232
# This `unsign` is identical to subclass except for the lower-casing

src/sentry/utils/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def log_gcp_credentials_details(logger: logging.Logger) -> None:
128128

129129

130130
def is_split_db() -> bool:
131-
if len(settings.DATABASES) != 1: # type: ignore[misc]
131+
if len(settings.DATABASES) != 1:
132132
return True
133-
for db in settings.DATABASES.values(): # type: ignore[misc]
133+
for db in settings.DATABASES.values():
134134
if db["NAME"] in {"region", "control"}:
135135
return True
136136
return False

0 commit comments

Comments
 (0)