mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 02:23:57 +00:00
mypy: Work around several new mypy bugs in 0.501.
This commit is contained in:
@@ -6,6 +6,8 @@ secondary Postgres servers' xlog location.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
if False: from mypy_extensions import NoReturn
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
@@ -17,7 +19,7 @@ states = {
|
||||
}
|
||||
|
||||
def report(state, msg):
|
||||
# type: (str, str) -> None
|
||||
# type: (str, str) -> NoReturn
|
||||
print("%s: %s" % (state, msg))
|
||||
exit(states[state])
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ def authenticated_rest_api_view(is_webhook=False):
|
||||
if isinstance(profile, UserProfile):
|
||||
request._email = profile.email
|
||||
else:
|
||||
assert isinstance(profile, Deployment)
|
||||
assert isinstance(profile, Deployment) # type: ignore # https://github.com/python/mypy/issues/2957
|
||||
request._email = "deployment:" + role
|
||||
profile.rate_limits = ""
|
||||
# Apply rate limiting
|
||||
|
||||
@@ -205,7 +205,7 @@ def valid_stream(stream_name, token):
|
||||
return False
|
||||
|
||||
def get_message_part_by_type(message, content_type):
|
||||
# type: (message.Message, Text) -> Text
|
||||
# type: (message.Message, Text) -> Optional[Text]
|
||||
charsets = message.get_charsets()
|
||||
|
||||
for idx, part in enumerate(message.walk()):
|
||||
@@ -215,6 +215,7 @@ def get_message_part_by_type(message, content_type):
|
||||
if charsets[idx]:
|
||||
text = content.decode(charsets[idx], errors="ignore")
|
||||
return text
|
||||
return None
|
||||
|
||||
def extract_body(message):
|
||||
# type: (message.Message) -> Text
|
||||
|
||||
@@ -44,7 +44,7 @@ class AddHeaderMixin(object):
|
||||
|
||||
super_class = super(AddHeaderMixin, self) # type: ignore # https://github.com/JukkaL/mypy/issues/857
|
||||
if hasattr(super_class, 'post_process'):
|
||||
super_ret = super_class.post_process(paths, dry_run, **kwargs)
|
||||
super_ret = super_class.post_process(paths, dry_run, **kwargs) # type: ignore # https://github.com/python/mypy/issues/2956
|
||||
else:
|
||||
super_ret = []
|
||||
|
||||
@@ -74,7 +74,7 @@ class RemoveUnminifiedFilesMixin(object):
|
||||
paths = {k: v for k, v in paths.items() if is_valid(k)}
|
||||
super_class = super(RemoveUnminifiedFilesMixin, self) # type: ignore # https://github.com/JukkaL/mypy/issues/857
|
||||
if hasattr(super_class, 'post_process'):
|
||||
return super_class.post_process(paths, dry_run, **kwargs)
|
||||
return super_class.post_process(paths, dry_run, **kwargs) # type: ignore # https://github.com/python/mypy/issues/2956
|
||||
|
||||
return []
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ def setup_event_queue():
|
||||
load_event_queues()
|
||||
atexit.register(dump_event_queues)
|
||||
# Make sure we dump event queues even if we exit via signal
|
||||
signal.signal(signal.SIGTERM, lambda signum, stack: sys.exit(1))
|
||||
signal.signal(signal.SIGTERM, lambda signum, stack: sys.exit(1)) # type: ignore # https://github.com/python/mypy/issues/2955
|
||||
tornado.autoreload.add_reload_hook(dump_event_queues) # type: ignore # TODO: Fix missing tornado.autoreload stub
|
||||
|
||||
try:
|
||||
|
||||
@@ -2,6 +2,8 @@ from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Union, Text
|
||||
if False:
|
||||
from mypy_extensions import NoReturn
|
||||
|
||||
import jinja2
|
||||
from django.utils import six
|
||||
@@ -31,7 +33,7 @@ class Jinja2(django_jinja2.Jinja2):
|
||||
super(Jinja2, self).__init__(params, *args, **kwargs)
|
||||
|
||||
def get_template(self, template_name):
|
||||
# type: (str) -> Template
|
||||
# type: (str) -> Any # should be Template, see https://github.com/python/mypy/issues/2958
|
||||
try:
|
||||
return Template(self.env.get_template(template_name),
|
||||
self.context_processors,
|
||||
|
||||
Reference in New Issue
Block a user