Skip to content

Commit

Permalink
Drop dependence on 'six' now we're Python 3 only
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJCLaw authored and lamby committed Jul 8, 2022
1 parent c00e649 commit f61fcce
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
4 changes: 1 addition & 3 deletions django_enumfield/enum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import difflib

import six

from .item import Item


Expand Down Expand Up @@ -73,7 +71,7 @@ def from_value(self, value):
raise ValueError("%r is not a valid value for enum %s" % (value, self.name))

def from_slug(self, slug):
if not isinstance(slug, six.string_types):
if not isinstance(slug, str):
raise TypeError("item slug should be a str, not %r" % type(slug))

try:
Expand Down
7 changes: 3 additions & 4 deletions django_enumfield/item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import six
import functools

from .utils import is_lazy_translation
Expand Down Expand Up @@ -34,7 +33,7 @@ def __init__(self, value, slug, display=None):

if (
display is not None
and not isinstance(display, six.string_types)
and not isinstance(display, str)
and not is_lazy_translation(display)
):
raise TypeError(
Expand All @@ -59,11 +58,11 @@ def __eq__(self, other):
if isinstance(other, Item):
return self.value == other.value

if isinstance(other, six.integer_types + six.string_types):
if isinstance(other, (int, str)):
try:
return self.value == int(other)
except ValueError:
return six.text_type(self.slug) == six.text_type(other)
return str(self.slug) == str(other)

return False

Expand Down
4 changes: 1 addition & 3 deletions django_enumfield/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import six

from django.http import Http404
from django.utils.functional import Promise

Expand Down Expand Up @@ -42,4 +40,4 @@ def is_lazy_translation(obj):
return False

resultclasses = obj.__reduce__()[1][3:]
return any(issubclass(x, six.string_types) for x in resultclasses)
return any(issubclass(x, str) for x in resultclasses)
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ commands =
coverage erase
coverage run --parallel-mode --branch --source ./django_enumfield runtests.py
deps =
six
coverage
django22: django==2.2
django32: django==3.2
Expand Down

0 comments on commit f61fcce

Please sign in to comment.