mypy: Fix inconsistencies in use of *args/**kwargs.

This commit is contained in:
Tim Abbott 2017-02-18 18:39:27 -08:00
parent 473c0ee1fe
commit 32bfebeb7a
10 changed files with 18 additions and 18 deletions

View File

@ -114,7 +114,7 @@ def get_config(ui, item):
return None return None
def hook(ui, repo, **kwargs): def hook(ui, repo, **kwargs):
# type: (ui, repo, Optional[Text]) -> None # type: (ui, repo, **Text) -> None
""" """
Invoked by configuring a [hook] entry in .hg/hgrc. Invoked by configuring a [hook] entry in .hg/hgrc.
""" """

View File

@ -4,7 +4,7 @@ import time
from psycopg2.extensions import cursor, connection from psycopg2.extensions import cursor, connection
from typing import Callable, Optional, Iterable, Any, Dict, Union, TypeVar, \ from typing import Callable, Optional, Iterable, Any, Dict, Union, TypeVar, \
Mapping, Sequence, Text Mapping, Text
from zerver.lib.str_utils import NonBinaryStr from zerver.lib.str_utils import NonBinaryStr
CursorObj = TypeVar('CursorObj', bound=cursor) CursorObj = TypeVar('CursorObj', bound=cursor)
@ -39,7 +39,7 @@ class TimeTrackingConnection(connection):
"""A psycopg2 connection class that uses TimeTrackingCursors.""" """A psycopg2 connection class that uses TimeTrackingCursors."""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# type: (Sequence[Any], Mapping[Text, Any]) -> None # type: (*Any, **Any) -> None
self.queries = [] # type: List[Dict[str, str]] self.queries = [] # type: List[Dict[str, str]]
super(TimeTrackingConnection, self).__init__(*args, **kwargs) super(TimeTrackingConnection, self).__init__(*args, **kwargs)

View File

@ -40,7 +40,7 @@ class Command(BaseCommand):
help='Remove all users in this realm from this stream.') help='Remove all users in this realm from this stream.')
def handle(self, **options): def handle(self, **options):
# type: (*Any, **Any) -> None # type: (**Any) -> None
if options["string_id"] is None or options["stream"] is None or \ if options["string_id"] is None or options["stream"] is None or \
(options["users"] is None and options["all_users"] is None): (options["users"] is None and options["all_users"] is None):
self.print_help("./manage.py", "remove_users_from_stream") self.print_help("./manage.py", "remove_users_from_stream")

View File

@ -37,7 +37,7 @@ Example:
'to post the fixture to') 'to post the fixture to')
def handle(self, **options): def handle(self, **options):
# type: (*Any, **str) -> None # type: (**str) -> None
if options['fixture'] is None or options['url'] is None: if options['fixture'] is None or options['url'] is None:
self.print_help('./manage.py', 'send_webhook_fixture_message') self.print_help('./manage.py', 'send_webhook_fixture_message')
exit(1) exit(1)

View File

@ -48,7 +48,7 @@ For example:
help='A comma-separated list of stream names.') help='A comma-separated list of stream names.')
def handle(self, **options): def handle(self, **options):
# type: (*Any, **str) -> None # type: (**str) -> None
if options["string_id"] is None or options["streams"] is None: if options["string_id"] is None or options["streams"] is None:
print("Please provide both a subdomain name or string_id and a default \ print("Please provide both a subdomain name or string_id and a default \
set of streams (which can be empty, with `--streams=`).", file=sys.stderr) set of streams (which can be empty, with `--streams=`).", file=sys.stderr)

View File

@ -241,7 +241,7 @@ class LogRequests(object):
connection.connection.queries = [] connection.connection.queries = []
def process_view(self, request, view_func, args, kwargs): def process_view(self, request, view_func, args, kwargs):
# type: (HttpRequest, Callable[..., HttpResponse], *str, **Any) -> None # type: (HttpRequest, Callable[..., HttpResponse], List[str], Dict[str, Any]) -> None
# process_request was already run; we save the initialization # process_request was already run; we save the initialization
# time (i.e. the time between receiving the request and # time (i.e. the time between receiving the request and
# figuring out which view function to call, which is primarily # figuring out which view function to call, which is primarily
@ -299,7 +299,7 @@ class JsonErrorHandler(object):
class TagRequests(object): class TagRequests(object):
def process_view(self, request, view_func, args, kwargs): def process_view(self, request, view_func, args, kwargs):
# type: (HttpRequest, Callable[..., HttpResponse], *str, **Any) -> None # type: (HttpRequest, Callable[..., HttpResponse], List[str], Dict[str, Any]) -> None
self.process_request(request) self.process_request(request)
def process_request(self, request): def process_request(self, request):

View File

@ -292,7 +292,7 @@ class RateLimitTestCase(TestCase):
req = Request() req = Request()
def f(req): def f(req):
# type: () -> str # type: (Any) -> str
return 'some value' return 'some value'
f = rate_limit()(f) f = rate_limit()(f)
@ -316,7 +316,7 @@ class RateLimitTestCase(TestCase):
req = Request() req = Request()
def f(req): def f(req):
# type: () -> str # type: (Any) -> str
return 'some value' return 'some value'
f = rate_limit()(f) f = rate_limit()(f)
@ -342,7 +342,7 @@ class RateLimitTestCase(TestCase):
req = Request() req = Request()
def f(req): def f(req):
# type: () -> str # type: (Any) -> str
return 'some value' return 'some value'
f = rate_limit()(f) f = rate_limit()(f)
@ -367,7 +367,7 @@ class RateLimitTestCase(TestCase):
req = Request() req = Request()
def f(req): def f(req):
# type: () -> str # type: (Any) -> str
return 'some value' return 'some value'
f = rate_limit()(f) f = rate_limit()(f)

View File

@ -261,7 +261,7 @@ class ExportTest(TestCase):
return values return values
def find_by_id(table, db_id): def find_by_id(table, db_id):
# type: (str) -> Dict[str, Any] # type: (str, int) -> Dict[str, Any]
return [ return [
r for r in data[table] r for r in data[table]
if r['id'] == db_id][0] if r['id'] == db_id][0]

View File

@ -37,7 +37,7 @@ class MockRedis(object):
del self.data[key] del self.data[key]
def expire(self, *args, **kwargs): def expire(self, *args, **kwargs):
# type: (Any, Any) -> None # type: (*Any, **Any) -> None
pass pass
class PushNotificationTest(TestCase): class PushNotificationTest(TestCase):
@ -75,7 +75,7 @@ class APNsMessageTest(PushNotificationTest):
class ResponseListenerTest(PushNotificationTest): class ResponseListenerTest(PushNotificationTest):
def get_error_response(self, **kwargs): def get_error_response(self, **kwargs):
# type: (Any) -> Dict[str, SupportsInt] # type: (**Any) -> Dict[str, SupportsInt]
er = {'identifier': 0, 'status': 0} # type: Dict[str, SupportsInt] er = {'identifier': 0, 'status': 0} # type: Dict[str, SupportsInt]
er.update({k: v for k, v in kwargs.items() if k in er}) er.update({k: v for k, v in kwargs.items() if k in er})
return er return er

View File

@ -38,7 +38,7 @@ def add_api_uri_context(context, request):
class ApiURLView(TemplateView): class ApiURLView(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
# type: (Optional[Dict[str, Any]]) -> Dict[str, str] # type: (**Any) -> Dict[str, str]
context = super(ApiURLView, self).get_context_data(**kwargs) context = super(ApiURLView, self).get_context_data(**kwargs)
add_api_uri_context(context, self.request) add_api_uri_context(context, self.request)
return context return context
@ -52,7 +52,7 @@ class HelpView(ApiURLView):
path_template = os.path.join(settings.DEPLOY_ROOT, 'templates/zerver/help/%s.md') path_template = os.path.join(settings.DEPLOY_ROOT, 'templates/zerver/help/%s.md')
def get_path(self, article): def get_path(self, article):
# type: (**Any) -> str # type: (str) -> str
if article == "": if article == "":
article = "index" article = "index"
return self.path_template % (article,) return self.path_template % (article,)
@ -84,7 +84,7 @@ class IntegrationView(ApiURLView):
template_name = 'zerver/integrations.html' template_name = 'zerver/integrations.html'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
# type: (Optional[Dict[str, Any]]) -> Dict[str, Any] # type: (**Any) -> Dict[str, Any]
context = super(IntegrationView, self).get_context_data(**kwargs) # type: Dict[str, Any] context = super(IntegrationView, self).get_context_data(**kwargs) # type: Dict[str, Any]
alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items())) alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
alphabetical_sorted_hubot_lozenges = OrderedDict(sorted(HUBOT_LOZENGES.items())) alphabetical_sorted_hubot_lozenges = OrderedDict(sorted(HUBOT_LOZENGES.items()))