Skip to content

Commit 3e0247c

Browse files
author
Tomáš Daniel
committed
chore: Django bump to <=5.0
1 parent 219f40b commit 3e0247c

24 files changed

+111
-121
lines changed

.github/workflows/django.yml

+2-12
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,8 @@ jobs:
1313
max-parallel: 4
1414
matrix:
1515
include:
16-
- python-version: 3.7
17-
django-version: Django==3.1
18-
19-
- python-version: 3.8
20-
django-version: Django==3.1
21-
22-
- python-version: 3.7
23-
django-version: Django==3.2
24-
25-
- python-version: 3.8
26-
django-version: Django==3.2
27-
16+
- python-version: 3.11
17+
django-version: Django==4.2
2818

2919
services:
3020
elasticsearch:

example/dj/apps/app/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.db import models
22
from django.db.models import Count
3-
from django.utils.translation import ugettext_lazy as _
3+
from django.utils.translation import gettext_lazy as _
44

55
from pyston.utils.decorators import order_by, filter_class, filter_by, allow_tags, sorter_class
66
from pyston.filters.filters import IntegerFilterMixin

example/dj/apps/app/tests/fields.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from django.conf import settings
55
from django.test.utils import override_settings
6-
from django.utils.translation import ugettext
6+
from django.utils.translation import gettext
77

88
from germanium.decorators import data_consumer
99
from germanium.tools.trivials import assert_in, assert_equal, assert_not_equal
@@ -440,7 +440,7 @@ def test_should_raise_bad_request_with_invalid_filename(self, number, data):
440440
assert_in('contract', errors)
441441
assert_equal(
442442
errors['contract'],
443-
ugettext('Content type cannot be evaluated from input data please send it')
443+
gettext('Content type cannot be evaluated from input data please send it')
444444
)
445445

446446
@data_consumer('get_users_data')
@@ -454,7 +454,7 @@ def test_should_raise_bad_request_if_file_content_is_not_in_base64(self, number,
454454
assert_http_bad_request(resp)
455455
errors = self.deserialize(resp).get('messages', {}).get('errors')
456456
assert_in('contract', errors)
457-
assert_equal(errors['contract']['content'], ugettext('File content must be in base64 format'))
457+
assert_equal(errors['contract']['content'], gettext('File content must be in base64 format'))
458458

459459
@data_consumer('get_users_data')
460460
def test_should_raise_bad_request_if_url_is_not_valid(self, number, data):
@@ -466,7 +466,7 @@ def test_should_raise_bad_request_if_url_is_not_valid(self, number, data):
466466
assert_http_bad_request(resp)
467467
errors = self.deserialize(resp).get('messages', {}).get('errors')
468468
assert_in('contract', errors)
469-
assert_equal(errors['contract']['url'], ugettext('Enter a valid URL.'))
469+
assert_equal(errors['contract']['url'], gettext('Enter a valid URL.'))
470470

471471
@data_consumer('get_users_data')
472472
def test_should_raise_bad_request_if_required_items_are_not_provided(self, number, data):
@@ -477,7 +477,7 @@ def test_should_raise_bad_request_if_required_items_are_not_provided(self, numbe
477477
assert_http_bad_request(resp)
478478
errors = self.deserialize(resp).get('messages', {}).get('errors')
479479
assert_in('contract', errors)
480-
msg = ugettext('File data item must contains {} or {}').format(
480+
msg = gettext('File data item must contains {} or {}').format(
481481
', '.join(REQUIRED_ITEMS), ', '.join(REQUIRED_URL_ITEMS)
482482
)
483483
assert_equal(errors['contract'], msg)
@@ -493,7 +493,7 @@ def test_should_raise_bad_request_if_file_is_unreachable(self, number, data):
493493
assert_http_bad_request(resp)
494494
errors = self.deserialize(resp).get('messages', {}).get('errors')
495495
assert_in('contract', errors)
496-
assert_equal(errors['contract']['url'], ugettext('File is unreachable on the URL address'))
496+
assert_equal(errors['contract']['url'], gettext('File is unreachable on the URL address'))
497497

498498
@override_settings(PYSTON_FILE_SIZE_LIMIT=10)
499499
@data_consumer('get_users_data')
@@ -509,7 +509,7 @@ def test_should_raise_bad_request_if_response_is_too_large(self, number, data):
509509
assert_http_bad_request(resp)
510510
errors = self.deserialize(resp).get('messages', {}).get('errors')
511511
assert_in('contract', errors)
512-
msg = ugettext('Response too large, maximum size is {} bytes').format(pyston_settings.FILE_SIZE_LIMIT)
512+
msg = gettext('Response too large, maximum size is {} bytes').format(pyston_settings.FILE_SIZE_LIMIT)
513513
assert_equal(errors['contract']['url'], msg)
514514

515515
@data_consumer('get_users_data')

example/dj/settings/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
try:
5-
from django.utils.translation import ugettext_lazy as _
5+
from django.utils.translation import gettext_lazy as _
66
except ImportError:
77
def _(val): return val
88

example/dj/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.conf import settings
2-
from django.conf.urls import url
2+
from django.urls import re_path as url
33

44
from app.dynamo.resource import CommentDynamoResource
55
from app.elasticsearch.resource import CommentElasticsearchResource

example/requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
botocore==1.29.165
22
coveralls
3-
Django<=3.2
3+
Django~=4.2
44
elasticsearch==7.13.4
55
elasticsearch-dsl==7.4.0
66
factory-boy==3.2.0
77
flake8
88
html5lib==1.1
99
pep8==1.6.2
1010
pillow>=8.0.1
11-
psycopg2-binary==2.8.6
11+
psycopg2-binary==2.9.5
1212
pynamodb==5.3.3
1313
pytz==2020.5
14-
reportlab==3.6.6
14+
reportlab==3.6.13
1515
responses==0.12.1
16-
skip-django-germanium==2.3.7.1
17-
skip-pydjamodb==0.0.10.1
18-
xhtml2pdf==0.2.5
16+
skip-django-germanium @ git+https://github.com/skip-pay/germanium@tda/chore/django_bump
17+
skip-pydjamodb @ git+https://github.com/skip-pay/pydjamodb@tda/chore/django_bump
18+
xhtml2pdf==0.2.11
1919
XlsxWriter==0.7.7
2020
-e ../

pyston/contrib/dynamo/paginator.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22
import json
33

4-
from django.utils.translation import ugettext
4+
from django.utils.translation import gettext
55

66
from pyston.exception import RestException
77
from pyston.paginator import BasePaginator
@@ -33,11 +33,11 @@ def _get_base(self, request):
3333
elif base.isdigit():
3434
base_int = int(base)
3535
if base_int > self.max_base:
36-
raise RestException(ugettext('Base must lower or equal to {}').format(self.max_base))
36+
raise RestException(gettext('Base must lower or equal to {}').format(self.max_base))
3737
else:
3838
return base_int
3939
else:
40-
raise RestException(ugettext('Base must be natural number or empty'))
40+
raise RestException(gettext('Base must be natural number or empty'))
4141

4242
def _get_cursor(self, request):
4343
cursor = request._rest_context.get('cursor')
@@ -48,7 +48,7 @@ def _get_cursor(self, request):
4848
).decode('ascii')
4949
return json.loads(cursor)
5050
except json.JSONDecodeError:
51-
raise RestException(ugettext('Invalid next cursor value'))
51+
raise RestException(gettext('Invalid next cursor value'))
5252
else:
5353
return None
5454

pyston/converters/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.core.serializers.json import DjangoJSONEncoder
1010
from django.http.response import HttpResponseBase
1111
from django.template.loader import get_template
12-
from django.utils.encoding import force_text
12+
from django.utils.encoding import force_str
1313
from django.utils.xmlutils import SimplerXMLGenerator
1414
from django.utils.module_loading import import_string
1515
from django.utils.html import format_html
@@ -175,7 +175,7 @@ def _to_xml(self, xml, data):
175175
self._to_xml(xml, value)
176176
xml.endElement(key)
177177
else:
178-
xml.characters(force_text(data))
178+
xml.characters(force_str(data))
179179

180180
def _encode(self, data, **kwargs):
181181
if data is not None:
@@ -287,7 +287,7 @@ def render_value(self, value, first=True):
287287
elif is_collection(value):
288288
return self._render_iterable(value, first)
289289
else:
290-
return force_text(value)
290+
return force_str(value)
291291

292292
def _get_value_from_row(self, data, field):
293293
return self.render_value(self._get_recursive_value_from_row(data, field.key_path) or '')
@@ -306,7 +306,7 @@ def _encode_to_stream(self, output_stream, data, resource=None, requested_fields
306306
**kwargs):
307307
fieldset = FieldsetGenerator(
308308
resource,
309-
force_text(requested_fields) if requested_fields is not None else None,
309+
force_str(requested_fields) if requested_fields is not None else None,
310310
direct_serialization=direct_serialization
311311
).generate()
312312
self.generator_class().generate(

pyston/converters/file_generators.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from decimal import Decimal
88

99
from django.conf import settings as django_settings
10-
from django.utils.encoding import force_text
10+
from django.utils.encoding import force_str
1111
from django.template.loader import get_template
1212

1313
try:
@@ -68,9 +68,9 @@ def _prepare_value(self, value):
6868
if isinstance(value, float):
6969
value = ('%.2f' % value).replace('.', ',')
7070
elif isinstance(value, Decimal):
71-
value = force_text(value.quantize(TWOPLACES)).replace('.', ',')
71+
value = force_str(value.quantize(TWOPLACES)).replace('.', ',')
7272
else:
73-
value = force_text(value)
73+
value = force_str(value)
7474
return value.replace('&nbsp;', ' ')
7575

7676

@@ -80,7 +80,7 @@ def __init__(self, f, dialect=csv.excel, use_bom=True, **kwargs):
8080
self.writer = csv.writer(f, dialect=dialect, **kwargs)
8181
self.stream = f
8282
if use_bom:
83-
self.stream.write(force_text(codecs.BOM_UTF8)) # BOM for Excel
83+
self.stream.write(force_str(codecs.BOM_UTF8)) # BOM for Excel
8484

8585
def writerow(self, row):
8686
self.writer.writerow(row)
@@ -105,7 +105,7 @@ def generate(self, header, data, output_stream):
105105
output_stream.write('{}:\n'.format(header[col]))
106106
if isinstance(val, str):
107107
val = self._prepare_value(val)
108-
output_stream.write('\t'.join(('\t' + force_text(val).lstrip()).splitlines(True)) + '\n\n')
108+
output_stream.write('\t'.join(('\t' + force_str(val).lstrip()).splitlines(True)) + '\n\n')
109109
output_stream.write('---\n')
110110

111111

@@ -127,7 +127,7 @@ def generate(self, header, data, output_stream):
127127

128128
if header:
129129
for col, head in enumerate(header):
130-
ws.write(row, col, force_text(head))
130+
ws.write(row, col, force_str(head))
131131
row += 1
132132

133133
for data_row in data:
@@ -163,7 +163,7 @@ def fetch_resources(uri, rel):
163163
return ''
164164

165165
pisa.pisaDocument(
166-
force_text(
166+
force_str(
167167
get_template(settings.PDF_EXPORT_TEMPLATE).render(
168168
{'pagesize': 'A4', 'headers': header, 'data': data}
169169
)

pyston/data_processor.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import BytesIO
77

88
from django.forms.fields import FileField
9-
from django.utils.translation import ugettext_lazy as _, ugettext
9+
from django.utils.translation import gettext_lazy as _, gettext
1010
from django.core.files.uploadedfile import InMemoryUploadedFile
1111
from django.core.validators import URLValidator
1212
from django.core.exceptions import ValidationError
@@ -82,7 +82,7 @@ class FileDataPreprocessor(DataProcessor):
8282
def _validate_not_empty(self, data_item, key, item):
8383
if not data_item.get(item):
8484
error = self.errors.get(key, RestDictError())
85-
error.update(RestDictError({item: RestValidationError(ugettext('This field is required'))}))
85+
error.update(RestDictError({item: RestValidationError(gettext('This field is required'))}))
8686
self.errors[key] = error
8787

8888
def _get_content_type(self, content_type, filename, file_content):
@@ -106,11 +106,11 @@ def _process_file_data(self, data, files, key, data_item, file_content):
106106
content_type = self._get_content_type(content_type, filename, file_content)
107107
filename = self._get_filename(content_type, filename)
108108
if not content_type:
109-
self.errors[key] = RestValidationError(ugettext(
109+
self.errors[key] = RestValidationError(gettext(
110110
'Content type cannot be evaluated from input data please send it'
111111
))
112112
elif not filename:
113-
self.errors[key] = RestValidationError(ugettext(
113+
self.errors[key] = RestValidationError(gettext(
114114
'File name cannot be evaluated from input data please send it'
115115
))
116116
else:
@@ -128,7 +128,7 @@ def _process_file_data_field(self, data, files, key, data_item):
128128
self._process_file_data(data, files, key, data_item, file_content)
129129
except (TypeError, binascii.Error):
130130
self.errors[key] = RestDictError({'content': RestValidationError(
131-
ugettext('File content must be in base64 format')
131+
gettext('File content must be in base64 format')
132132
)})
133133

134134
def _process_file_data_url_field(self, data, files, key, data_item):
@@ -144,13 +144,13 @@ def _process_file_data_url_field(self, data, files, key, data_item):
144144
self._process_file_data(data, files, key, data_item, file_content)
145145
except RequestDataTooBig:
146146
self.errors[key] = RestDictError({'url': RestValidationError(
147-
ugettext('Response too large, maximum size is {} bytes').format(
147+
gettext('Response too large, maximum size is {} bytes').format(
148148
pyston_settings.FILE_SIZE_LIMIT
149149
))
150150
})
151151
except (RequestException, InvalidResponseStatusCode):
152152
self.errors[key] = RestDictError({'url': RestValidationError(
153-
ugettext('File is unreachable on the URL address')
153+
gettext('File is unreachable on the URL address')
154154
)})
155155
try:
156156
url_validator(url)
@@ -177,7 +177,7 @@ def _process_field(self, data, files, key, data_item):
177177
self._process_file_data_url_field(data, files, key, data_item)
178178
else:
179179
self.errors[key] = RestValidationError(
180-
ugettext('File data item must contains {} or {}').format(
180+
gettext('File data item must contains {} or {}').format(
181181
', '.join(REQUIRED_ITEMS), ', '.join(REQUIRED_URL_ITEMS)
182182
)
183183
)

pyston/exception.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.utils.translation import ugettext_lazy as _
1+
from django.utils.translation import gettext_lazy as _
22

33

44
class UnsupportedMediaTypeException(Exception):

0 commit comments

Comments
 (0)