Created
January 28, 2020 23:55
-
-
Save Callek/74f2bcc77a0c261405df57ac50c870fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to_unicode {{{1 | |
def to_unicode(line: AnyStr) -> str: | |
"""Avoid ``b'line'`` type messages in the logs. | |
Args: | |
line (str): The bytecode or unicode string. | |
Returns: | |
str: the unicode-decoded string, if ``line`` was a bytecode string. | |
Otherwise return ``line`` unmodified. | |
""" | |
try: | |
line = line.decode("utf-8") | |
except (UnicodeDecodeError, AttributeError): | |
pass | |
return line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/scriptworker/utils.py:127: error: "str" has no attribute "decode"; maybe "encode"? | |
src/scriptworker/utils.py:127: error: Incompatible types in assignment (expression has type "str", variable has type "bytes") | |
src/scriptworker/utils.py:130: error: Incompatible return value type (got "bytes", expected "str") | |
src/scriptworker/log.py:81: error: Incompatible types in assignment (expression has type "str", variable has type "bytes") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment