Skip to content

Commit c2ee13b

Browse files
committed
drop Python2 support
1 parent 4cdc806 commit c2ee13b

File tree

9 files changed

+15
-38
lines changed

9 files changed

+15
-38
lines changed

netfields/compat.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@
99
from django.db.backends.postgresql.base import is_psycopg3
1010
except ImportError:
1111
is_psycopg3 = False
12-
13-
if VERSION[0] <= 2:
14-
from django.utils.six import with_metaclass, text_type
15-
else:
16-
from six import with_metaclass, text_type

netfields/fields.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from netaddr import EUI
66
from netaddr.core import AddrFormatError
77

8-
from netfields.compat import DatabaseWrapper, is_psycopg3, with_metaclass, text_type
8+
from netfields.compat import DatabaseWrapper, is_psycopg3
99
from netfields.forms import (
1010
InetAddressFormField,
1111
NoPrefixInetAddressFormField,
@@ -202,7 +202,7 @@ def get_prep_value(self, value):
202202
if not value:
203203
return None
204204

205-
return text_type(self.to_python(value))
205+
return str(self.to_python(value))
206206

207207
def get_db_prep_value(self, value, connection, prepared=False):
208208
# Django <= 1.8, ArrayField does not pass model to the base_field so we have to check for existance
@@ -248,7 +248,7 @@ def get_prep_value(self, value):
248248
if not value:
249249
return None
250250

251-
return text_type(self.to_python(value))
251+
return str(self.to_python(value))
252252

253253
def get_db_prep_value(self, value, connection, prepared=False):
254254
# Django <= 1.8, ArrayField does not pass model to the base_field, so we have to check for existence
@@ -266,4 +266,4 @@ def get_db_prep_value(self, value, connection, prepared=False):
266266
def formfield(self, **kwargs):
267267
defaults = {'form_class': MACAddress8FormField}
268268
defaults.update(kwargs)
269-
return super(MACAddress8Field, self).formfield(**defaults)
269+
return super(MACAddress8Field, self).formfield(**defaults)

netfields/forms.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django import forms
55
from django.core.exceptions import ValidationError
66

7-
from netfields.compat import text_type
87
from netfields.mac import mac_unix_common, mac_eui64
98

109

@@ -24,7 +23,7 @@ def to_python(self, value):
2423
if isinstance(value, _IPAddressBase):
2524
return value
2625

27-
if isinstance(value, text_type):
26+
if isinstance(value, str):
2827
value = value.strip()
2928

3029
try:
@@ -49,7 +48,7 @@ def to_python(self, value):
4948
if isinstance(value, _IPAddressBase):
5049
return value
5150

52-
if isinstance(value, text_type):
51+
if isinstance(value, str):
5352
value = value.strip()
5453

5554
try:
@@ -75,7 +74,7 @@ def to_python(self, value):
7574
if isinstance(value, _BaseNetwork):
7675
network = value
7776

78-
if isinstance(value, text_type):
77+
if isinstance(value, str):
7978
value = value.strip()
8079

8180
try:
@@ -103,7 +102,7 @@ def to_python(self, value):
103102
if isinstance(value, EUI):
104103
return value
105104

106-
if isinstance(value, text_type):
105+
if isinstance(value, str):
107106
value = value.strip()
108107

109108
try:
@@ -132,7 +131,7 @@ def to_python(self, value):
132131
if isinstance(value, EUI):
133132
return value
134133

135-
if isinstance(value, text_type):
134+
if isinstance(value, str):
136135
value = value.strip()
137136

138137
try:

netfields/rest_framework.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from __future__ import absolute_import
2-
31
from ipaddress import ip_address, ip_interface, ip_network
42

53
from netaddr import EUI
64
from netaddr.core import AddrFormatError
75
from rest_framework import serializers
86

9-
from netfields.compat import text_type
107
from netfields.mac import mac_unix_common, mac_eui64
118
from netfields import fields
129

@@ -23,7 +20,7 @@ def __init__(self, store_prefix=True, *args, **kwargs):
2320
def to_representation(self, value):
2421
if value is None:
2522
return value
26-
return text_type(value)
23+
return str(value)
2724

2825
def to_internal_value(self, data):
2926
if data is None:
@@ -46,7 +43,7 @@ class CidrAddressField(serializers.Field):
4643
def to_representation(self, value):
4744
if value is None:
4845
return value
49-
return text_type(value)
46+
return str(value)
5047

5148
def to_internal_value(self, data):
5249
if data is None:
@@ -67,7 +64,7 @@ class MACAddressField(serializers.Field):
6764
def to_representation(self, value):
6865
if value is None:
6966
return value
70-
return text_type(value)
67+
return str(value)
7168

7269
def to_internal_value(self, data):
7370
if data is None:
@@ -86,7 +83,7 @@ class MACAddress8Field(serializers.Field):
8683
def to_representation(self, value):
8784
if value is None:
8885
return value
89-
return text_type(value)
86+
return str(value)
9087

9188
def to_internal_value(self, data):
9289
if data is None:

setup.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from distutils.core import setup
44

55
import os
6-
import sys
7-
86

97
def get_long_description():
108
path = os.path.join(os.path.dirname(__file__), 'README.rst')
@@ -15,12 +13,8 @@ def get_long_description():
1513
requirements = [
1614
'netaddr',
1715
'django>=1.8',
18-
'six',
1916
]
2017

21-
if sys.version_info.major == 2:
22-
requirements.append('ipaddress')
23-
2418
setup(
2519
name='django-netfields',
2620
version='1.3.2',
@@ -44,6 +38,7 @@ def get_long_description():
4438
'License :: OSI Approved :: BSD License',
4539
'Operating System :: OS Independent',
4640
'Programming Language :: Python',
41+
'Programming Language :: Python :: 3',
4742
'Topic :: Utilities',
4843
],
4944
)

test/tests/test_form_fields.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import unicode_literals
21
from ipaddress import ip_address, ip_interface, ip_network
32
from netaddr import EUI
43

test/tests/test_functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import unicode_literals
21
from django import VERSION
32
from ipaddress import ip_interface, ip_network
43
from netaddr import EUI

test/tests/test_rest_framework_fields.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
from __future__ import absolute_import, unicode_literals
2-
31
from rest_framework import serializers
42
import sys
5-
6-
if sys.version_info.major == 2:
7-
import unittest2 as unittest
8-
else:
9-
import unittest
3+
import unittest
104

115
from netfields import rest_framework as fields
126

test/tests/test_sql_fields.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import unicode_literals
21
import warnings
32
import django
43
from django import VERSION

0 commit comments

Comments
 (0)