Skip to content

Commit

Permalink
drop basestring hack, Python 2 is no more
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni authored and ekohl committed Nov 19, 2024
1 parent 5ab3ab9 commit c947eff
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions apypie/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from apypie.param import Param
from apypie.exceptions import MissingArgumentsError, InvalidArgumentTypesError

try:
basestring # type: ignore[used-before-def] # pylint: disable=used-before-assignment
except NameError: # Python 3 has no basestring
basestring = str # pylint: disable=invalid-name,redefined-builtin

if TYPE_CHECKING:
from apypie.api import Api # pylint: disable=cyclic-import,unused-import # noqa: F401

Expand Down Expand Up @@ -159,7 +154,7 @@ def _validate(self, params, values, data=None, files=None, path=None): # pylint
self._validate(param_description.params, item, path=self._add_to_path(path, [param_description.name, str(num)]))
elif param_description.expected_type == 'hash':
self._validate(param_description.params, value, path=self._add_to_path(path, [param_description.name]))
if (param_description.expected_type == 'numeric' and isinstance(value, basestring)):
if (param_description.expected_type == 'numeric' and isinstance(value, str)):
try:
value = int(value)
except ValueError:
Expand All @@ -171,7 +166,7 @@ def _validate(self, params, values, data=None, files=None, path=None): # pylint
if (value is not None
and ((param_description.expected_type == 'boolean' and not isinstance(value, bool) and not (isinstance(value, int) and value in [0, 1]))
or (param_description.expected_type == 'numeric' and not isinstance(value, int))
or (param_description.expected_type == 'string' and not isinstance(value, (basestring, int))))):
or (param_description.expected_type == 'string' and not isinstance(value, (str, int))))):
raise ValueError("{} ({}): {}".format(param, value, param_description.validator))

@staticmethod
Expand Down

0 comments on commit c947eff

Please sign in to comment.