From 3b18f4e4a24acadfc6f3a092fd427ce7c408c4ce Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Tue, 10 Oct 2023 17:06:38 -0400 Subject: [PATCH] fix flake8 errors --- python/ola/StringUtils.py | 6 +++--- tools/rdm/ResponderTest.py | 6 +++--- tools/rdm/TestHelpers.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/ola/StringUtils.py b/python/ola/StringUtils.py index a0f51cfafd..4a4d7dd7de 100644 --- a/python/ola/StringUtils.py +++ b/python/ola/StringUtils.py @@ -32,11 +32,11 @@ def StringEscape(s): """Escape unprintable characters in a string.""" # TODO(Peter): How does this interact with the E1.20 Unicode flag? # We don't use sys.version_info.major to support Python 2.6. - if sys.version_info[0] == 2 and type(s) == str: + if sys.version_info[0] == 2 and isinstance(s, str): return s.encode('string-escape') - elif sys.version_info[0] == 2 and type(s) == unicode: + elif sys.version_info[0] == 2 and isinstance(s, unicode): return s.encode('unicode-escape') - elif type(s) == str: + elif isinstance(s, str): # All strings in Python 3 are unicode # This encode/decode pair gets us an escaped string return s.encode('unicode-escape').decode(encoding="ascii", diff --git a/tools/rdm/ResponderTest.py b/tools/rdm/ResponderTest.py index 93490306ff..23a6f532da 100644 --- a/tools/rdm/ResponderTest.py +++ b/tools/rdm/ResponderTest.py @@ -612,15 +612,15 @@ def _CheckForAckOrNack(self, response, unpacked_data, unpack_exception): return True def _EscapeData(self, data): - if type(data) == list: + if isinstance(data, list): return [self._EscapeData(i) for i in data] - elif type(data) == dict: + elif isinstance(data, dict): d = {} for k, v in data.items(): # We can't escape the key as then it may become a new key d[k] = self._EscapeData(v) return d - elif type(data) == str or type(data) == unicode: + elif isinstance(data, str) or isinstance(data, unicode): return StringEscape(data) else: return data diff --git a/tools/rdm/TestHelpers.py b/tools/rdm/TestHelpers.py index 51eb606de7..4a157bcf63 100644 --- a/tools/rdm/TestHelpers.py +++ b/tools/rdm/TestHelpers.py @@ -31,7 +31,7 @@ def ContainsUnprintable(s): """Check if a string s contain unprintable characters.""" # TODO(Peter): How does this interact with the E1.20 Unicode flag? - if type(s) == str or type(s) == unicode: + if isinstance(s, str) or isinstance(s, unicode): # All strings in Python 3 are unicode, Python 2 ones might not be return s != StringEscape(s) else: