diff --git a/api/bin/zulip-send b/api/bin/zulip-send index 5d3adbd288..d85b47cea1 100755 --- a/api/bin/zulip-send +++ b/api/bin/zulip-send @@ -122,7 +122,7 @@ def main(argv=None): if not do_send_message(client, message_data): return 1 - + return 0 if __name__ == '__main__': sys.exit(main()) diff --git a/api/integrations/hg/zulip-changegroup.py b/api/integrations/hg/zulip-changegroup.py index c0bb9cac49..21dc923cf4 100755 --- a/api/integrations/hg/zulip-changegroup.py +++ b/api/integrations/hg/zulip-changegroup.py @@ -87,7 +87,7 @@ def format_commit_lines(web_url, repo, base, tip): return "\n".join(summary for summary in commit_summaries) def send_zulip(email, api_key, site, stream, subject, content): - # type: (str, str, str, str, str, Text) -> str + # type: (str, str, str, str, str, Text) -> None """ Send a message to Zulip using the provided credentials, which should be for a bot in most cases. diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index e10a26f225..1d9bcbb726 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -86,7 +86,7 @@ def release_deployment_lock(): shutil.rmtree(LOCK_DIR) def run(args, **kwargs): - # type: (Sequence[str], **Any) -> int + # type: (Sequence[str], **Any) -> None # Output what we're doing in the `set -x` style print("+ %s" % (" ".join(args))) diff --git a/tools/check-urls b/tools/check-urls index 892f3add77..cae048bfee 100755 --- a/tools/check-urls +++ b/tools/check-urls @@ -7,7 +7,7 @@ import sys def check_urls(): - # type: () -> bool + # type: () -> None url_files = ['zproject/urls.py', 'zproject/dev_urls.py', 'zproject/legacy_urls.py', diff --git a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py index 452b9f717a..d54b556b73 100644 --- a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py @@ -97,3 +97,4 @@ class BaseDocumentationSpider(scrapy.Spider): self._set_error_state() else: raise Exception(failure.value) + return None diff --git a/tools/lib/find_add_class.py b/tools/lib/find_add_class.py index ae3f037ec2..0755254d1c 100644 --- a/tools/lib/find_add_class.py +++ b/tools/lib/find_add_class.py @@ -57,6 +57,7 @@ def generic(html_class): for kw in GENERIC_KEYWORDS: if kw in html_class: return True + return False def display(fns): # type: (List[str]) -> None diff --git a/tools/lib/html_branches.py b/tools/lib/html_branches.py index 528a294dc9..9a2b927dad 100644 --- a/tools/lib/html_branches.py +++ b/tools/lib/html_branches.py @@ -144,13 +144,11 @@ def split_for_id_and_class(element): def html_branches(text, fn=None): # type: (str, str) -> List[HtmlTreeBranch] - tree = html_tag_tree(text) branches = [] # type: List[HtmlTreeBranch] def walk(node, tag_info_list=None): - # type: (Node, Optional[List[TagInfo]]) -> Node - + # type: (Node, Optional[List[TagInfo]]) -> None info = get_tag_info(node.token) if tag_info_list is None: tag_info_list = [info] @@ -195,7 +193,6 @@ def html_tag_tree(text): def build_id_dict(templates): # type: (List[str]) -> (Dict[str,List[str]]) - template_id_dict = defaultdict(list) # type: (Dict[str,List[str]]) for fn in templates: diff --git a/tools/run-dev.py b/tools/run-dev.py index 86e1492cbf..c0ecbc1e03 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -241,6 +241,7 @@ class BaseWebsocketHandler(WebSocketHandler): # close websocket proxy connection if no connection with target websocket server return self.close() self.client.write_message(message, binary) + return None def check_origin(self, origin): # type: (str) -> bool @@ -262,6 +263,7 @@ class CombineHandler(BaseWebsocketHandler): # type: (*Any, **Any) -> Optional[Callable] if self.request.headers.get("Upgrade", "").lower() == 'websocket': return super(CombineHandler, self).get(*args, **kwargs) + return None def head(self): # type: () -> None diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index ac112865d9..d7b6929b0f 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -402,6 +402,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): if yt_id is not None: return "https://i.ytimg.com/vi/%s/default.jpg" % (yt_id,) + return None def twitter_text(self, text, urls, user_mentions, media): # type: (Text, List[Dict[Text, Text]], List[Dict[Text, Any]], List[Dict[Text, Any]]) -> Element @@ -972,7 +973,7 @@ class UserMentionPattern(markdown.inlinepatterns.Pattern): el.set('data-user-id', user_id) el.text = "@%s" % (name,) return el - + return None class StreamPattern(VerbosePattern): def find_stream_by_name(self, name): @@ -1001,7 +1002,7 @@ class StreamPattern(VerbosePattern): stream_name=urllib.parse.quote(force_str(name)))) el.text = u'#{stream_name}'.format(stream_name=name) return el - + return None class AlertWordsNotificationProcessor(markdown.preprocessors.Preprocessor): def run(self, lines): diff --git a/zerver/lib/i18n.py b/zerver/lib/i18n.py index fac8a7683f..fa3d5f92c2 100644 --- a/zerver/lib/i18n.py +++ b/zerver/lib/i18n.py @@ -72,6 +72,7 @@ def get_language_name(code): for lang in get_language_list(): if lang['code'] == code: return lang['name'] + return None def get_available_language_codes(): # type: () -> List[Text] diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index b31e3fb4df..7c8cf4a6f7 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -194,20 +194,22 @@ def make_client(name): return client def find_key_by_email(address): - # type: (Text) -> Text + # type: (Text) -> Optional[Text] from django.core.mail import outbox key_regex = re.compile("accounts/do_confirm/([a-f0-9]{40})>") for message in reversed(outbox): if address in message.to: return key_regex.search(message.body).groups()[0] + return None def find_pattern_in_email(address, pattern): - # type: (Text, Text) -> Text + # type: (Text, Text) -> Optional[Text] from django.core.mail import outbox key_regex = re.compile(pattern) for message in reversed(outbox): if address in message.to: return key_regex.search(message.body).group(0) + return None def message_ids(result): # type: (Dict[str, Any]) -> Set[int] diff --git a/zerver/lib/utils.py b/zerver/lib/utils.py index 58c1bb44fa..31a5d957a8 100644 --- a/zerver/lib/utils.py +++ b/zerver/lib/utils.py @@ -41,7 +41,7 @@ class StatsDWrapper(object): # as our statsd server supports them but supporting # pystatsd is not released yet def _our_gauge(self, stat, value, rate=1, delta=False): - # type: (str, float, float, bool) -> str + # type: (str, float, float, bool) -> None """Set a gauge value.""" from django_statsd.clients import statsd if delta: diff --git a/zerver/models.py b/zerver/models.py index c283430638..3e221f20c3 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -1354,6 +1354,8 @@ class UserPresence(models.Model): return 'active' elif status == UserPresence.IDLE: return 'idle' + else: + raise ValueError('Unknown status: %s' % (status,)) @staticmethod def get_status_dict_by_user(user_profile): diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 7de8d4cacc..c37f1f568d 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -470,6 +470,7 @@ class ValidatorTestCase(TestCase): ])('_', val) if error: return 'This is not a valid person' + return None person = {'name': 'King Lear', 'age': 42} self.assertEqual(check_person(person), None) diff --git a/zproject/backends.py b/zproject/backends.py index 345f061ed6..5cd3e85d04 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -278,6 +278,7 @@ class GoogleMobileOauth2Backend(ZulipAuthMixin): return user_profile else: return_data["valid_attestation"] = False + return None class ZulipRemoteUserBackend(RemoteUserBackend): create_unknown_user = False