summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clauss <cclauss@me.com>2020-07-28 17:50:18 +0200
committerGitHub <noreply@github.com>2020-07-28 21:50:18 +0600
commit92b8c32717191e420bf30734247b7a3b2ef1af0f (patch)
treee77031164ff72080c337551963921d8d2b349f19
parented35d9f0a91561909d8eead4f64365660f728a9c (diff)
downloadkombu-4.x.tar.gz
flake8: noqa the Python 2-only builtins (#1228)4.x
* flake8: noqa the Python 2-only builtin cmp() * flake8: buffer() was removed in Python 3 * flake8: unicode() was removed in Python3 because all str are Unicode Adds the modifications from #1227
-rw-r--r--kombu/utils/encoding.py10
-rw-r--r--kombu/utils/functional.py4
-rw-r--r--t/unit/utils/test_json.py2
3 files changed, 8 insertions, 8 deletions
diff --git a/kombu/utils/encoding.py b/kombu/utils/encoding.py
index 551cf5f3..1c845af5 100644
--- a/kombu/utils/encoding.py
+++ b/kombu/utils/encoding.py
@@ -76,7 +76,7 @@ else:
def str_to_bytes(s): # noqa
"""Convert str to bytes."""
- if isinstance(s, unicode):
+ if isinstance(s, unicode): # noqa: F821
return s.encode()
return s
@@ -90,9 +90,9 @@ else:
def default_encode(obj, file=None): # noqa
"""Get default encoding."""
- return unicode(obj, default_encoding(file))
+ return unicode(obj, default_encoding(file)) # noqa: F821
- str_t = unicode
+ str_t = unicode # noqa: F821
ensure_bytes = str_to_bytes
@@ -130,10 +130,10 @@ else:
def _safe_str(s, errors='replace', file=None): # noqa
encoding = default_encoding(file)
try:
- if isinstance(s, unicode):
+ if isinstance(s, unicode): # noqa: F821
return _ensure_str(s.encode(encoding, errors),
encoding, errors)
- return unicode(s, encoding, errors)
+ return unicode(s, encoding, errors) # noqa: F821
except Exception as exc:
return '<Unrepresentable {0!r}: {1!r} {2!r}>'.format(
type(s), exc, '\n'.join(traceback.format_stack()))
diff --git a/kombu/utils/functional.py b/kombu/utils/functional.py
index b191a759..3fbb5d46 100644
--- a/kombu/utils/functional.py
+++ b/kombu/utils/functional.py
@@ -236,8 +236,8 @@ class lazy(object):
def __cmp__(self, rhs):
if isinstance(rhs, self.__class__):
- return -cmp(rhs, self())
- return cmp(self(), rhs)
+ return -cmp(rhs, self()) # noqa: F821
+ return cmp(self(), rhs) # noqa: F821
def maybe_evaluate(value):
diff --git a/t/unit/utils/test_json.py b/t/unit/utils/test_json.py
index ae7b374d..b694443e 100644
--- a/t/unit/utils/test_json.py
+++ b/t/unit/utils/test_json.py
@@ -83,7 +83,7 @@ class test_dumps_loads:
@skip.if_python3()
def test_loads_buffer(self):
- assert loads(buffer(dumps({'x': 'z'}))) == {'x': 'z'}
+ assert loads(buffer(dumps({'x': 'z'}))) == {'x': 'z'} # noqa: F821
def test_loads_DecodeError(self):
_loads = Mock(name='_loads')