diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-10-16 20:56:46 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-10-16 20:56:46 -0700 |
commit | 5a07892bfc58472c1b651f66deaf03176bfe79df (patch) | |
tree | 6b6a7f449721c3b3515c9ae36e5be03b610c7967 /netlib/strutils.py | |
parent | 3fbce7e981cab5d20b3ef17a50f14b34e8c60fa3 (diff) | |
download | mitmproxy-5a07892bfc58472c1b651f66deaf03176bfe79df.tar.gz mitmproxy-5a07892bfc58472c1b651f66deaf03176bfe79df.tar.bz2 mitmproxy-5a07892bfc58472c1b651f66deaf03176bfe79df.zip |
py2--: inline type info
Diffstat (limited to 'netlib/strutils.py')
-rw-r--r-- | netlib/strutils.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/netlib/strutils.py b/netlib/strutils.py index 81e95792..1f7db949 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -43,14 +43,13 @@ _control_char_trans = str.maketrans(_control_char_trans) _control_char_trans_newline = str.maketrans(_control_char_trans_newline) -def escape_control_characters(text, keep_spacing=True): +def escape_control_characters(text: str, keep_spacing=True) -> str: """ Replace all unicode C1 control characters from the given text with a single "." Args: keep_spacing: If True, tabs and newlines will not be replaced. """ - # type: (str) -> str if not isinstance(text, str): raise ValueError("text type must be unicode but is {}".format(type(text).__name__)) @@ -101,8 +100,7 @@ def escaped_str_to_bytes(data): return codecs.escape_decode(data)[0] -def is_mostly_bin(s): - # type: (bytes) -> bool +def is_mostly_bin(s: bytes) -> bool: if not s or len(s) == 0: return False @@ -112,8 +110,7 @@ def is_mostly_bin(s): ) / len(s[:100]) > 0.3 -def is_xml(s): - # type: (bytes) -> bool +def is_xml(s: bytes) -> bool: return s.strip().startswith(b"<") |