Skip to content

Commit

Permalink
Merge pull request #1911 from DaAwesomeP/DaAwesomeP-fix-flake8-error
Browse files Browse the repository at this point in the history
Fix flake8 errors
  • Loading branch information
peternewman authored Oct 23, 2023
2 parents 0a5c7ce + 3ad7d96 commit f3074fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions python/ola/StringUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tools/rdm/ResponderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/rdm/TestHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f3074fe

Please sign in to comment.