Browse Source

ref: replace deprecated django.conf.urls.url with django.urls.re_path (#52302)

deprecated (and very noisy) in django 3.x, removed in 4.x
anthony sottile 1 year ago
parent
commit
1631df05d1

+ 2 - 2
src/sentry/admin.py

@@ -2,7 +2,6 @@ from html import escape
 
 from django import forms
 from django.conf import settings
-from django.conf.urls import url
 from django.contrib import admin, messages
 from django.contrib.auth.forms import AdminPasswordChangeForm
 from django.contrib.auth.forms import UserChangeForm as DjangoUserChangeForm
@@ -12,6 +11,7 @@ from django.db import transaction
 from django.http import Http404, HttpResponseRedirect
 from django.shortcuts import get_object_or_404
 from django.template.response import TemplateResponse
+from django.urls import re_path
 from django.utils.decorators import method_decorator
 from django.utils.translation import gettext
 from django.utils.translation import gettext_lazy as _
@@ -198,7 +198,7 @@ class UserAdmin(admin.ModelAdmin):
 
     def get_urls(self):
         return [
-            url(r"^(\d+)/password/$", self.admin_site.admin_view(self.user_change_password))
+            re_path(r"^(\d+)/password/$", self.admin_site.admin_view(self.user_change_password))
         ] + super().get_urls()
 
     def lookup_allowed(self, lookup, value):

File diff suppressed because it is too large
+ 172 - 171
src/sentry/api/urls.py


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

@@ -300,7 +300,7 @@ def method_dispatch(**dispatch_mapping):
     """
     Dispatches a incoming request to a different handler based on the HTTP method
 
-    >>> url('^foo$', method_dispatch(POST = post_handler, GET = get_handler)))
+    >>> re_path('^foo$', method_dispatch(POST = post_handler, GET = get_handler)))
     """
 
     def invalid_method(request, *args, **kwargs):

+ 4 - 5
src/sentry/conf/urls.py

@@ -1,8 +1,7 @@
 from __future__ import annotations
 
 from django.conf import settings
-from django.conf.urls import url
-from django.urls import URLPattern, URLResolver
+from django.urls import URLPattern, URLResolver, re_path
 
 from sentry.web.frontend import csrf_failure
 from sentry.web.frontend.error_404 import Error404View
@@ -13,17 +12,17 @@ handler404 = Error404View.as_view()
 handler500 = Error500View.as_view()
 
 urlpatterns: list[URLResolver | URLPattern] = [
-    url(
+    re_path(
         r"^500/",
         handler500,
         name="error-500",
     ),
-    url(
+    re_path(
         r"^404/",
         handler404,
         name="error-404",
     ),
-    url(
+    re_path(
         r"^403-csrf-failure/",
         csrf_failure.view,
         name="error-403-csrf-failure",

+ 3 - 2
src/sentry/django_admin.py

@@ -1,7 +1,8 @@
 from copy import copy
 
-from django.conf.urls import include, url
+from django.conf.urls import include
 from django.contrib import admin
+from django.urls import re_path
 
 from sentry.auth.superuser import is_active_superuser
 
@@ -32,4 +33,4 @@ def make_site():
 
 site = make_site()
 
-urlpatterns = [url(r"^admin/", include(site.urls[:2]))]
+urlpatterns = [re_path(r"^admin/", include(site.urls[:2]))]

+ 6 - 6
src/sentry/integrations/bitbucket/urls.py

@@ -1,4 +1,4 @@
-from django.conf.urls import url
+from django.urls import re_path
 
 from .descriptor import BitbucketDescriptorEndpoint
 from .installed import BitbucketInstalledEndpoint
@@ -7,24 +7,24 @@ from .uninstalled import BitbucketUninstalledEndpoint
 from .webhook import BitbucketWebhookEndpoint
 
 urlpatterns = [
-    url(
+    re_path(
         r"^descriptor/$",
         BitbucketDescriptorEndpoint.as_view(),
     ),
-    url(
+    re_path(
         r"^installed/$",
         BitbucketInstalledEndpoint.as_view(),
     ),
-    url(
+    re_path(
         r"^uninstalled/$",
         BitbucketUninstalledEndpoint.as_view(),
     ),
-    url(
+    re_path(
         r"^organizations/(?P<organization_id>[^\/]+)/webhook/$",
         BitbucketWebhookEndpoint.as_view(),
         name="sentry-extensions-bitbucket-webhook",
     ),
-    url(
+    re_path(
         r"^search/(?P<organization_slug>[^\/]+)/(?P<integration_id>\d+)/$",
         BitbucketSearchEndpoint.as_view(),
         name="sentry-extensions-bitbucket-search",

+ 2 - 2
src/sentry/integrations/bitbucket_server/urls.py

@@ -1,9 +1,9 @@
-from django.conf.urls import url
+from django.urls import re_path
 
 from .webhook import BitbucketServerWebhookEndpoint
 
 urlpatterns = [
-    url(
+    re_path(
         r"^organizations/(?P<organization_id>[^\/]+)/webhook/(?P<integration_id>\d+)/$",
         BitbucketServerWebhookEndpoint.as_view(),
         name="sentry-extensions-bitbucketserver-webhook",

+ 3 - 3
src/sentry/integrations/github/urls.py

@@ -1,15 +1,15 @@
-from django.conf.urls import url
+from django.urls import re_path
 
 from .search import GitHubSearchEndpoint
 from .webhook import GitHubIntegrationsWebhookEndpoint
 
 urlpatterns = [
-    url(
+    re_path(
         r"^webhook/$",
         GitHubIntegrationsWebhookEndpoint.as_view(),
         name="sentry-integration-github-webhook",
     ),
-    url(
+    re_path(
         r"^search/(?P<organization_slug>[^\/]+)/(?P<integration_id>\d+)/$",
         GitHubSearchEndpoint.as_view(),
         name="sentry-integration-github-search",

+ 2 - 2
src/sentry/integrations/github_enterprise/urls.py

@@ -1,9 +1,9 @@
-from django.conf.urls import url
+from django.urls import re_path
 
 from .webhook import GitHubEnterpriseWebhookEndpoint
 
 urlpatterns = [
-    url(
+    re_path(
         r"^webhook/$",
         GitHubEnterpriseWebhookEndpoint.as_view(),
     )

+ 3 - 3
src/sentry/integrations/gitlab/urls.py

@@ -1,15 +1,15 @@
-from django.conf.urls import url
+from django.urls import re_path
 
 from .search import GitlabIssueSearchEndpoint
 from .webhooks import GitlabWebhookEndpoint
 
 urlpatterns = [
-    url(
+    re_path(
         r"^search/(?P<organization_slug>[^\/]+)/(?P<integration_id>\d+)/$",
         GitlabIssueSearchEndpoint.as_view(),
         name="sentry-extensions-gitlab-search",
     ),
-    url(
+    re_path(
         r"^webhook/$",
         GitlabWebhookEndpoint.as_view(),
         name="sentry-extensions-gitlab-webhook",

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