zerver/lib/actions.py: Use text_type in truncate_ functions.

The functions truncate_content, truncate_body and truncate_topic
are only meant to be used on text strings.  So change its
parameter types from AnyStr to text_type.
This commit is contained in:
Eklavya Sharma 2016-07-05 03:20:24 +05:30 committed by Tim Abbott
parent 976858f536
commit 628e45defc
2 changed files with 3 additions and 4 deletions

View File

@ -40,7 +40,6 @@ zerver/tests/test_narrow.py
exclude_py2 = []
exclude_py3 = """
zerver/lib/actions.py
zerver/lib/ccache.py
zerver/management/commands/create_stream.py
zerver/management/commands/email-mirror.py

View File

@ -2313,17 +2313,17 @@ def subscribed_to_stream(user_profile, stream):
return False
def truncate_content(content, max_length, truncation_message):
# type: (AnyStr, int, AnyStr) -> AnyStr
# type: (text_type, int, text_type) -> text_type
if len(content) > max_length:
content = content[:max_length - len(truncation_message)] + truncation_message
return content
def truncate_body(body):
# type: (AnyStr) -> AnyStr
# type: (text_type) -> text_type
return truncate_content(body, MAX_MESSAGE_LENGTH, "...")
def truncate_topic(topic):
# type: (AnyStr) -> AnyStr
# type: (text_type) -> text_type
return truncate_content(topic, MAX_SUBJECT_LENGTH, "...")