misc: change django-upgrade target version to 3.2 (#75442)

This commit is contained in:
Valentin Deniaud 2023-03-15 14:13:36 +01:00
parent 3772e5546b
commit f4bca2d2fe
7 changed files with 18 additions and 27 deletions

View File

@ -17,10 +17,10 @@ repos:
- id: pyupgrade
args: ['--keep-percent-format', '--py37-plus']
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.10.0
rev: 1.13.0
hooks:
- id: django-upgrade
args: ['--target-version', '2.2']
args: ['--target-version', '3.2']
- repo: https://github.com/rtts/djhtml
rev: 'v1.5.2'
hooks:

2
README
View File

@ -46,7 +46,7 @@ pyupgrade is used to automatically upgrade syntax, using those parameters:
django-upgrade is used to automatically upgrade Django syntax, using those parameters:
django-upgrade --target-version 2.2
django-upgrade --target-version 3.2
djhtml is used to automatically indent html files, using those parameters:

View File

@ -15,9 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.apps import apps
from django.contrib.postgres.fields import JSONField
from django.core.management.base import BaseCommand, CommandError
from django.db import connection
from django.db.models import JSONField
class Command(BaseCommand):

View File

@ -33,7 +33,7 @@ from dateutil.rrule import DAILY, WEEKLY, rrule, rruleset
from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.humanize.templatetags.humanize import ordinal
from django.contrib.postgres.fields import ArrayField, JSONField
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import connection, models, transaction
@ -44,6 +44,7 @@ from django.db.models import (
F,
Func,
IntegerField,
JSONField,
Max,
OuterRef,
Prefetch,
@ -1689,22 +1690,12 @@ class Event(models.Model):
if agendas:
overlapping_events = overlapping_events.filter(agenda__in=agendas)
if django.VERSION >= (3, 2):
from django.db.models.functions import JSONObject
from django.db.models.functions import JSONObject
json_object = JSONObject(
slug=F('computed_slug'),
days=F('recurrence_days'),
)
else:
json_object = Func(
Value('slug'),
'computed_slug',
Value('days'),
'recurrence_days',
function='jsonb_build_object',
output_field=JSONField(),
)
json_object = JSONObject(
slug=F('computed_slug'),
days=F('recurrence_days'),
)
return qs.annotate(
overlaps=ArraySubquery(
@ -2142,7 +2133,7 @@ class Booking(models.Model):
user_first_name = models.CharField(max_length=250, blank=True)
user_email = models.EmailField(blank=True)
user_phone_number = models.CharField(max_length=30, blank=True)
user_was_present = models.NullBooleanField()
user_was_present = models.BooleanField(null=True)
user_check_type_slug = models.CharField(max_length=160, blank=True, null=True)
user_check_type_label = models.CharField(max_length=150, blank=True, null=True)
out_of_min_delay = models.BooleanField(default=False)

View File

@ -83,7 +83,7 @@ WSGI_APPLICATION = 'chrono.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': 'django.db.backends.postgresql',
}
}

View File

@ -28,15 +28,15 @@ from .views import LoginView, LogoutView, homepage
urlpatterns = [
path('', homepage, name='home'),
re_path(r'^manage/', decorated_includes(login_required, include(chrono_manager_urls))),
re_path(r'^api/', include(chrono_api_urls)),
path('api/', include(chrono_api_urls)),
path('logout/', LogoutView.as_view(), name='auth_logout'),
path('login/', LoginView.as_view(), name='auth_login'),
]
if 'mellon' in settings.INSTALLED_APPS:
urlpatterns.append(
re_path(
r'^accounts/mellon/',
path(
'accounts/mellon/',
include('mellon.urls'),
kwargs={
'template_base': 'chrono/manager_base.html',
@ -48,7 +48,7 @@ if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar # pylint: disable=import-error
urlpatterns = [
re_path(r'^__debug__/', include(debug_toolbar.urls)),
path('__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
# static and media files

View File

@ -10,7 +10,7 @@ REST_FRAMEWORK = {
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': 'django.db.backends.postgresql',
'TEST': {
'NAME': 'chrono-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:45],
},