aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/strutils.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-10-16 21:17:39 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-10-16 21:17:39 -0700
commit9389601025415c47d5efaa6ac371ddca6d543f48 (patch)
tree7a2fa561d702425ccec7edbc5a35108523e3f33d /netlib/strutils.py
parentae3ff8ee1edc646e7a640219df1a312c27f7c339 (diff)
parent5a07892bfc58472c1b651f66deaf03176bfe79df (diff)
downloadmitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.tar.gz
mitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.tar.bz2
mitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.zip
Merge branch 'such-types'
Diffstat (limited to 'netlib/strutils.py')
-rw-r--r--netlib/strutils.py9
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"<")