mypy: Add --disallow-any=generics & extend typing accordingly.
Also reset typing of ExternalBotHandler to Any after discussion.
This commit is contained in:
parent
424a4bb631
commit
28687f18ca
10 changed files with 54 additions and 51 deletions
|
@ -435,7 +435,7 @@ class Client(object):
|
|||
)
|
||||
|
||||
def do_api_query(self, orig_request, url, method="POST", longpolling=False, files=None):
|
||||
# type: (Mapping[str, Any], str, str, bool, List[IO]) -> Dict[str, Any]
|
||||
# type: (Mapping[str, Any], str, str, bool, List[IO[Any]]) -> Dict[str, Any]
|
||||
if files is None:
|
||||
files = []
|
||||
|
||||
|
@ -568,14 +568,14 @@ class Client(object):
|
|||
"status_code": res.status_code}
|
||||
|
||||
def call_endpoint(self, url=None, method="POST", request=None, longpolling=False, files=None):
|
||||
# type: (str, str, Dict[str, Any], bool, List[IO]) -> Dict[str, Any]
|
||||
# type: (str, str, Dict[str, Any], bool, List[IO[Any]]) -> Dict[str, Any]
|
||||
if request is None:
|
||||
request = dict()
|
||||
return self.do_api_query(request, API_VERSTRING + url, method=method,
|
||||
longpolling=longpolling, files=files)
|
||||
|
||||
def call_on_each_event(self, callback, event_types=None, narrow=None):
|
||||
# type: (Callable, Optional[List[str]], Any) -> None
|
||||
# type: (Callable[[Any], None], Optional[List[str]], Any) -> None
|
||||
if narrow is None:
|
||||
narrow = []
|
||||
|
||||
|
@ -635,7 +635,7 @@ class Client(object):
|
|||
callback(event)
|
||||
|
||||
def call_on_each_message(self, callback):
|
||||
# type: (Callable) -> None
|
||||
# type: (Callable[[Any], None]) -> None
|
||||
def event_callback(event):
|
||||
# type: (Dict[str, str]) -> None
|
||||
if event['type'] == 'message':
|
||||
|
@ -653,7 +653,7 @@ class Client(object):
|
|||
)
|
||||
|
||||
def upload_file(self, file):
|
||||
# type: (IO) -> Dict[str, Any]
|
||||
# type: (IO[Any]) -> Dict[str, Any]
|
||||
'''
|
||||
See examples/upload-file for example usage.
|
||||
'''
|
||||
|
|
|
@ -25,7 +25,7 @@ from __future__ import print_function
|
|||
import argparse
|
||||
|
||||
from six.moves import StringIO as _StringIO
|
||||
from typing import IO
|
||||
from typing import IO, Any
|
||||
import zulip
|
||||
|
||||
class StringIO(_StringIO):
|
||||
|
@ -47,7 +47,7 @@ options = parser.parse_args()
|
|||
|
||||
client = zulip.init_from_options(options)
|
||||
|
||||
file = None # type: IO
|
||||
file = None # type: IO[Any]
|
||||
if options.file_path:
|
||||
file = open(options.file_path, 'rb')
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue