Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3c75579

Browse filesBrowse files
authored
Cleanup dependencies and conditions for unsupported Python versions (#9681)
* Remove optional install backports.zoneinfo for unsupported Python versions and associated code * Remove conditions in tests for unsupported Python versions * Remove condition for unsupported Python versions
1 parent c41314f commit 3c75579
Copy full SHA for 3c75579

File tree

Expand file treeCollapse file tree

9 files changed

+16
-73
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+16
-73
lines changed

‎rest_framework/utils/serializer_helpers.py

Copy file name to clipboardExpand all lines: rest_framework/utils/serializer_helpers.py
+14-16Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import contextlib
2-
import sys
32
from collections.abc import Mapping, MutableMapping
43

54
from django.utils.encoding import force_str
@@ -29,21 +28,20 @@ def __reduce__(self):
2928
# but preserve the raw data.
3029
return (dict, (dict(self),))
3130

32-
if sys.version_info >= (3, 9):
33-
# These are basically copied from OrderedDict, with `serializer` added.
34-
def __or__(self, other):
35-
if not isinstance(other, dict):
36-
return NotImplemented
37-
new = self.__class__(self, serializer=self.serializer)
38-
new.update(other)
39-
return new
40-
41-
def __ror__(self, other):
42-
if not isinstance(other, dict):
43-
return NotImplemented
44-
new = self.__class__(other, serializer=self.serializer)
45-
new.update(self)
46-
return new
31+
# These are basically copied from OrderedDict, with `serializer` added.
32+
def __or__(self, other):
33+
if not isinstance(other, dict):
34+
return NotImplemented
35+
new = self.__class__(self, serializer=self.serializer)
36+
new.update(other)
37+
return new
38+
39+
def __ror__(self, other):
40+
if not isinstance(other, dict):
41+
return NotImplemented
42+
new = self.__class__(other, serializer=self.serializer)
43+
new.update(self)
44+
return new
4745

4846

4947
class ReturnList(list):

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_version(package):
8181
author_email='tom@tomchristie.com', # SEE NOTE BELOW (*)
8282
packages=find_packages(exclude=['tests*']),
8383
include_package_data=True,
84-
install_requires=["django>=4.2", 'backports.zoneinfo;python_version<"3.9"'],
84+
install_requires=["django>=4.2"],
8585
python_requires=">=3.9",
8686
zip_safe=False,
8787
classifiers=[

‎tests/test_fields.py

Copy file name to clipboardExpand all lines: tests/test_fields.py
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import math
33
import os
44
import re
5-
import sys
65
import uuid
76
import warnings
87
from decimal import ROUND_DOWN, ROUND_UP, Decimal
98
from enum import auto
109
from unittest.mock import patch
10+
from zoneinfo import ZoneInfo
1111

1212
import pytest
1313

@@ -30,11 +30,6 @@
3030
)
3131
from tests.models import UUIDForeignKeyTarget
3232

33-
if sys.version_info >= (3, 9):
34-
from zoneinfo import ZoneInfo
35-
else:
36-
from backports.zoneinfo import ZoneInfo
37-
3833
utc = datetime.timezone.utc
3934

4035
# Tests for helper functions.
@@ -641,10 +636,6 @@ def test_parent_binding(self):
641636

642637

643638
class TestTyping(TestCase):
644-
@pytest.mark.skipif(
645-
sys.version_info < (3, 7),
646-
reason="subscriptable classes requires Python 3.7 or higher",
647-
)
648639
def test_field_is_subscriptable(self):
649640
assert serializers.Field is serializers.Field["foo"]
650641

‎tests/test_generics.py

Copy file name to clipboardExpand all lines: tests/test_generics.py
-14Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import pytest
42
from django.db import models
53
from django.http import Http404
@@ -703,23 +701,11 @@ def list(self, request):
703701

704702

705703
class TestTyping(TestCase):
706-
@pytest.mark.skipif(
707-
sys.version_info < (3, 7),
708-
reason="subscriptable classes requires Python 3.7 or higher",
709-
)
710704
def test_genericview_is_subscriptable(self):
711705
assert generics.GenericAPIView is generics.GenericAPIView["foo"]
712706

713-
@pytest.mark.skipif(
714-
sys.version_info < (3, 7),
715-
reason="subscriptable classes requires Python 3.7 or higher",
716-
)
717707
def test_listview_is_subscriptable(self):
718708
assert generics.ListAPIView is generics.ListAPIView["foo"]
719709

720-
@pytest.mark.skipif(
721-
sys.version_info < (3, 7),
722-
reason="subscriptable classes requires Python 3.7 or higher",
723-
)
724710
def test_instanceview_is_subscriptable(self):
725711
assert generics.RetrieveAPIView is generics.RetrieveAPIView["foo"]

‎tests/test_model_serializer.py

Copy file name to clipboardExpand all lines: tests/test_model_serializer.py
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import decimal
1010
import json # noqa
1111
import re
12-
import sys
1312
import tempfile
1413

1514
import pytest
@@ -397,10 +396,6 @@ class Meta:
397396
fields = '__all__'
398397

399398
expected = dedent("""
400-
TestSerializer():
401-
id = IntegerField(label='ID', read_only=True)
402-
duration_field = DurationField(max_value=datetime.timedelta(3), min_value=datetime.timedelta(1))
403-
""") if sys.version_info < (3, 7) else dedent("""
404399
TestSerializer():
405400
id = IntegerField(label='ID', read_only=True)
406401
duration_field = DurationField(max_value=datetime.timedelta(days=3), min_value=datetime.timedelta(days=1))

‎tests/test_request.py

Copy file name to clipboardExpand all lines: tests/test_request.py
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import copy
55
import os.path
6-
import sys
76
import tempfile
87

98
import pytest
@@ -375,9 +374,5 @@ def test_deepcopy_works(self):
375374

376375

377376
class TestTyping(TestCase):
378-
@pytest.mark.skipif(
379-
sys.version_info < (3, 7),
380-
reason="subscriptable classes requires Python 3.7 or higher",
381-
)
382377
def test_request_is_subscriptable(self):
383378
assert Request is Request["foo"]

‎tests/test_response.py

Copy file name to clipboardExpand all lines: tests/test_response.py
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
3-
import pytest
41
from django.test import TestCase, override_settings
52
from django.urls import include, path, re_path
63

@@ -289,9 +286,5 @@ def test_form_has_label_and_help_text(self):
289286

290287

291288
class TestTyping(TestCase):
292-
@pytest.mark.skipif(
293-
sys.version_info < (3, 7),
294-
reason="subscriptable classes requires Python 3.7 or higher",
295-
)
296289
def test_response_is_subscriptable(self):
297290
assert Response is Response["foo"]

‎tests/test_serializer.py

Copy file name to clipboardExpand all lines: tests/test_serializer.py
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import inspect
22
import pickle
33
import re
4-
import sys
54
from collections import ChainMap
65
from collections.abc import Mapping
76

@@ -205,10 +204,6 @@ class ExampleSerializer(serializers.Serializer):
205204
exceptions.ErrorDetail(string='Raised error', code='invalid')
206205
]}
207206

208-
@pytest.mark.skipif(
209-
sys.version_info < (3, 7),
210-
reason="subscriptable classes requires Python 3.7 or higher",
211-
)
212207
def test_serializer_is_subscriptable(self):
213208
assert serializers.Serializer is serializers.Serializer["foo"]
214209

@@ -743,10 +738,6 @@ class TestSerializer(A, B):
743738

744739

745740
class Test8301Regression:
746-
@pytest.mark.skipif(
747-
sys.version_info < (3, 9),
748-
reason="dictionary union operator requires Python 3.9 or higher",
749-
)
750741
def test_ReturnDict_merging(self):
751742
# Serializer.data returns ReturnDict, this is essentially a test for that.
752743

‎tests/test_serializer_lists.py

Copy file name to clipboardExpand all lines: tests/test_serializer_lists.py
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import pytest
42
from django.http import QueryDict
53
from django.utils.datastructures import MultiValueDict
@@ -60,10 +58,6 @@ def test_validate_html_input(self):
6058
assert serializer.is_valid()
6159
assert serializer.validated_data == expected_output
6260

63-
@pytest.mark.skipif(
64-
sys.version_info < (3, 7),
65-
reason="subscriptable classes requires Python 3.7 or higher",
66-
)
6761
def test_list_serializer_is_subscriptable(self):
6862
assert serializers.ListSerializer is serializers.ListSerializer["foo"]
6963

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.