mirror of https://github.com/zulip/zulip.git
mypy: Fix some new errors flagged by latest mypy master.
Mostly list -> List bugs in annotations.
This commit is contained in:
parent
e0813c7288
commit
9866124b78
|
@ -573,7 +573,7 @@ def zephyr_to_zulip(options):
|
|||
process_loop(None)
|
||||
|
||||
def send_zephyr(zwrite_args, content):
|
||||
# type: (list, str) -> Tuple[int, str]
|
||||
# type: (List, str) -> Tuple[int, str]
|
||||
p = subprocess.Popen(zwrite_args, stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate(input=content.encode("utf-8"))
|
||||
|
@ -590,11 +590,11 @@ def send_zephyr(zwrite_args, content):
|
|||
return (p.returncode, stderr)
|
||||
|
||||
def send_authed_zephyr(zwrite_args, content):
|
||||
# type: (list[str], str) -> Tuple[int, str]
|
||||
# type: (List[str], str) -> Tuple[int, str]
|
||||
return send_zephyr(zwrite_args, content)
|
||||
|
||||
def send_unauthed_zephyr(zwrite_args, content):
|
||||
# type: (list[str], str) -> Tuple[int, str]
|
||||
# type: (List[str], str) -> Tuple[int, str]
|
||||
return send_zephyr(zwrite_args + ["-d"], content)
|
||||
|
||||
def zcrypt_encrypt_content(zephyr_class, instance, content):
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from typing import List, Set, Tuple
|
||||
from typing import DefaultDict, List, Set, Tuple
|
||||
|
||||
class Graph(object):
|
||||
def __init__(self, *tuples):
|
||||
# type: (Tuple[str, str]) -> None
|
||||
self.children = defaultdict(list) # type: defaultdict[str, List[str]]
|
||||
self.parents = defaultdict(list) # type: defaultdict[str, List[str]]
|
||||
self.children = defaultdict(list) # type: DefaultDict[str, List[str]]
|
||||
self.parents = defaultdict(list) # type: DefaultDict[str, List[str]]
|
||||
self.nodes = set() # type: Set[str]
|
||||
|
||||
for parent, child in tuples:
|
||||
|
|
|
@ -162,7 +162,7 @@ def send_to_missed_message_address(address, message):
|
|||
# Testing with basestring so we don't depend on the list return type from
|
||||
# get_display_recipient
|
||||
if not isinstance(display_recipient, six.string_types):
|
||||
recipient_str = ','.join([user['email'] for user in display_recipient])
|
||||
recipient_str = u','.join([user['email'] for user in display_recipient])
|
||||
else:
|
||||
recipient_str = display_recipient
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
from typing import Any, Dict, List, Set, Tuple, TypeVar, Text, \
|
||||
from typing import Any, DefaultDict, Dict, List, Set, Tuple, TypeVar, Text, \
|
||||
Union, Optional, Sequence, AbstractSet, Pattern, AnyStr
|
||||
from typing.re import Match
|
||||
from zerver.lib.str_utils import NonBinaryStr
|
||||
|
@ -473,7 +473,7 @@ def realm_filters_for_realm_remote_cache(realm_id):
|
|||
|
||||
def all_realm_filters():
|
||||
# type: () -> Dict[int, List[Tuple[Text, Text, int]]]
|
||||
filters = defaultdict(list) # type: Dict[int, List[Tuple[Text, Text, int]]]
|
||||
filters = defaultdict(list) # type: DefaultDict[int, List[Tuple[Text, Text, int]]]
|
||||
for realm_filter in RealmFilter.objects.all():
|
||||
filters[realm_filter.realm_id].append((realm_filter.pattern, realm_filter.url_format_string, realm_filter.id))
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ class UserPresence(models.Model):
|
|||
|
||||
@staticmethod
|
||||
def get_status_dict_by_user(user_profile):
|
||||
# type: (UserProfile) -> defaultdict[Any, Dict[Any, Any]]
|
||||
# type: (UserProfile) -> DefaultDict[Any, Dict[Any, Any]]
|
||||
query = UserPresence.objects.filter(user_profile=user_profile).values(
|
||||
'client__name',
|
||||
'status',
|
||||
|
@ -1385,7 +1385,7 @@ class UserPresence(models.Model):
|
|||
|
||||
@staticmethod
|
||||
def get_status_dict_by_realm(realm_id):
|
||||
# type: (int) -> defaultdict[Any, Dict[Any, Any]]
|
||||
# type: (int) -> DefaultDict[Any, Dict[Any, Any]]
|
||||
query = UserPresence.objects.filter(
|
||||
user_profile__realm_id=realm_id,
|
||||
user_profile__is_active=True,
|
||||
|
@ -1410,8 +1410,8 @@ class UserPresence(models.Model):
|
|||
|
||||
@staticmethod
|
||||
def get_status_dicts_for_query(query, mobile_user_ids):
|
||||
# type: (QuerySet, List[int]) -> defaultdict[Any, Dict[Any, Any]]
|
||||
user_statuses = defaultdict(dict) # type: defaultdict[Any, Dict[Any, Any]]
|
||||
# type: (QuerySet, List[int]) -> DefaultDict[Any, Dict[Any, Any]]
|
||||
user_statuses = defaultdict(dict) # type: DefaultDict[Any, Dict[Any, Any]]
|
||||
# Order of query is important to get a latest status as aggregated status.
|
||||
for row in query.order_by("user_profile__id", "-timestamp"):
|
||||
info = UserPresence.to_presence_dict(
|
||||
|
|
|
@ -959,7 +959,7 @@ class GetOldMessagesTest(ZulipTestCase):
|
|||
"""
|
||||
self.login("hamlet@zulip.com")
|
||||
|
||||
other_params = [("anchor", 0), ("num_before", 0), ("num_after", 0)] # type: list[Tuple[Text, Union[int, str, bool]]]
|
||||
other_params = [("anchor", 0), ("num_before", 0), ("num_after", 0)] # type: List[Tuple[Text, Union[int, str, bool]]]
|
||||
|
||||
bad_types = (False, 0, '', '{malformed json,',
|
||||
'{foo: 3}', '[1,2]', '[["x","y","z"]]') # type: Tuple[Union[int, str, bool], ...]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# See http://zulip.readthedocs.io/en/latest/events-system.html for
|
||||
# high-level documentation on how this system works.
|
||||
from __future__ import absolute_import
|
||||
from typing import cast, AbstractSet, Any, Callable, Dict, List, Mapping, MutableMapping, Optional, Iterable, Sequence, Set, Text, Union
|
||||
from typing import cast, AbstractSet, Any, Callable, Deque, Dict, List, \
|
||||
Mapping, MutableMapping, Optional, Iterable, Sequence, Set, Text, Union
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
|
@ -231,7 +232,7 @@ def compute_full_event_type(event):
|
|||
class EventQueue(object):
|
||||
def __init__(self, id):
|
||||
# type: (str) -> None
|
||||
self.queue = deque() # type: deque[Dict[str, Any]]
|
||||
self.queue = deque() # type: Deque[Dict[str, Any]]
|
||||
self.next_event_id = 0 # type: int
|
||||
self.id = id # type: str
|
||||
self.virtual_events = {} # type: Dict[str, Dict[str, Any]]
|
||||
|
|
|
@ -85,7 +85,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
|||
|
||||
# Set up middleware if needed. We couldn't do this earlier, because
|
||||
# settings weren't available.
|
||||
self._request_middleware = None # type: ignore # Should be List[Callable[[WSGIRequest], Any]] https://github.com/JukkaL/mypy/issues/1174
|
||||
self._request_middleware = None
|
||||
self.initLock.acquire()
|
||||
# Check that middleware is still uninitialised.
|
||||
if self._request_middleware is None:
|
||||
|
@ -161,7 +161,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
|||
response = None
|
||||
|
||||
# Apply request middleware
|
||||
for middleware_method in self._request_middleware:
|
||||
for middleware_method in self._request_middleware: # type: ignore # Should be List[Callable[[WSGIRequest], Any]] https://github.com/JukkaL/mypy/issues/1174
|
||||
response = middleware_method(request)
|
||||
if response:
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue