From 628e45defc349826442cd891b279f03a9c49c73a Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Tue, 5 Jul 2016 03:20:24 +0530 Subject: [PATCH] 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. --- tools/run-mypy | 1 - zerver/lib/actions.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/run-mypy b/tools/run-mypy index 171d6e2216..46b02e892b 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -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 diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 2398f796c6..eb0a590d0d 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.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, "...")