Skip to content

Commit

Permalink
validators: drop six usage (#186)
Browse files Browse the repository at this point in the history
As python 3.4 is the required version there's no need to keep six for Python 2
compat.
  • Loading branch information
xrmx committed Mar 1, 2021
1 parent f7221ba commit 95e5f00
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -33,7 +33,6 @@ def get_version():
}

install_requires = [
'six>=1.4.0',
'decorator>=3.4.0',
]

Expand Down
4 changes: 1 addition & 3 deletions tests/test_validation_failure.py
@@ -1,5 +1,3 @@
import six

import validators

obj_repr = (
Expand All @@ -19,7 +17,7 @@ def test_repr(self):
assert obj_repr in repr(self.obj)

def test_unicode(self):
assert obj_repr in six.text_type(self.obj)
assert obj_repr in str(self.obj)

def test_arguments_as_properties(self):
assert self.obj.value == 3
Expand Down
10 changes: 1 addition & 9 deletions validators/domain.py
@@ -1,15 +1,7 @@
import re

import six

from .utils import validator

if six.PY3:
text_type = str
unicode = str
else:
text_type = unicode

pattern = re.compile(
r'^(?:[a-zA-Z0-9]' # First character of the domain
r'(?:[a-zA-Z0-9-_]{0,61}[A-Za-z0-9])?\.)' # Sub domain + hostname
Expand All @@ -22,7 +14,7 @@ def to_unicode(obj, charset='utf-8', errors='strict'):
if obj is None:
return None
if not isinstance(obj, bytes):
return text_type(obj)
return str(obj)
return obj.decode(charset, errors)


Expand Down
4 changes: 1 addition & 3 deletions validators/truthy.py
@@ -1,5 +1,3 @@
import six

from .utils import validator


Expand Down Expand Up @@ -37,5 +35,5 @@ def truthy(value):
"""
return (
value and
(not isinstance(value, six.string_types) or value.strip())
(not isinstance(value, str) or value.strip())
)
8 changes: 2 additions & 6 deletions validators/utils.py
Expand Up @@ -2,7 +2,6 @@
import itertools
from collections import OrderedDict

import six
from decorator import decorator


Expand Down Expand Up @@ -37,10 +36,7 @@ def func_args_as_dict(func, args, kwargs):
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
_getargspec = inspect.getfullargspec

arg_names = list(
OrderedDict.fromkeys(
Expand All @@ -51,7 +47,7 @@ def func_args_as_dict(func, args, kwargs):
)
)
return OrderedDict(
list(six.moves.zip(arg_names, args)) +
list(zip(arg_names, args)) +
list(kwargs.items())
)

Expand Down

0 comments on commit 95e5f00

Please sign in to comment.