mirror of https://github.com/zulip/zulip.git
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:
parent
976858f536
commit
628e45defc
|
@ -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
|
||||
|
|
|
@ -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, "...")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue