Skip to content

Commit 538352c

Browse files
committed
Upgrade mypy to latest version
As part of this change I had to convert from type comments to type annotations so I could use the `com2ann -> no_implicit_optional` tools to automatically convert new issues found.
1 parent 58d401d commit 538352c

File tree

15 files changed

+1592
-1349
lines changed

15 files changed

+1592
-1349
lines changed

chalice/api/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
to mature so for the time being this is an internal-only API.
66
"""
77
import os
8-
from typing import Dict, Any
8+
from typing import Optional, Dict, Any
99
from chalice.cli.factory import CLIFactory
1010

1111

12-
def package_app(project_dir, output_dir, stage, chalice_config=None,
13-
package_format='cloudformation', template_format='json'):
14-
# type: (str, str, str, Dict[str, Any], str, str) -> None
12+
def package_app(project_dir: str,
13+
output_dir: str,
14+
stage: str,
15+
chalice_config: Optional[Dict[str, Any]] = None,
16+
package_format: str = 'cloudformation',
17+
template_format: str = 'json') -> None:
1518
factory = CLIFactory(project_dir, environ=os.environ)
1619
if chalice_config is None:
1720
chalice_config = {}

chalice/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ def on_ws_message(self, name: Optional[str] = None) -> Callable[..., Any]:
871871

872872
def _create_registration_function(self, handler_type: str,
873873
name: Optional[str] = None,
874-
registration_kwargs: Any = None
874+
registration_kwargs: Optional[Any] = None
875875
) -> Callable[..., Any]:
876876
def _register_handler(
877877
user_handler: UserHandlerFuncType
@@ -935,7 +935,7 @@ def _register_handler(self, handler_type: str, name: str,
935935
user_handler: UserHandlerFuncType,
936936
wrapped_handler: Callable[..., Any],
937937
kwargs: Dict[str, Any],
938-
options: Dict[Any, Any] = None) -> None:
938+
options: Optional[Dict[Any, Any]] = None) -> None:
939939
raise NotImplementedError("_register_handler")
940940

941941
def register_middleware(self, func: MiddlewareFuncType,
@@ -962,7 +962,7 @@ def register_middleware(self, func: MiddlewareFuncType,
962962
def _do_register_handler(self, handler_type: str, name: str,
963963
user_handler: UserHandlerFuncType,
964964
wrapped_handler: Callable[..., Any], kwargs: Any,
965-
options: Dict[Any, Any] = None) -> None:
965+
options: Optional[Dict[Any, Any]] = None) -> None:
966966
module_name = 'app'
967967
if options is not None:
968968
name_prefix = options.get('name_prefix')
@@ -1223,7 +1223,7 @@ class Chalice(_HandlerRegistration, DecoratorAPI):
12231223

12241224
def __init__(self, app_name: str, debug: bool = False,
12251225
configure_logs: bool = True,
1226-
env: MutableMapping = None) -> None:
1226+
env: Optional[MutableMapping] = None) -> None:
12271227
super(Chalice, self).__init__()
12281228
self.app_name: str = app_name
12291229
self.websocket_api: WebsocketAPI = WebsocketAPI()
@@ -1292,7 +1292,8 @@ def register_blueprint(self, blueprint: 'Blueprint',
12921292
def _register_handler(self, handler_type: str, name: str,
12931293
user_handler: UserHandlerFuncType,
12941294
wrapped_handler: Callable[..., Any],
1295-
kwargs: Any, options: Dict[Any, Any] = None) -> None:
1295+
kwargs: Any, options: Optional[Dict[Any, Any]] = None
1296+
) -> None:
12961297
self._do_register_handler(handler_type, name, user_handler,
12971298
wrapped_handler, kwargs, options)
12981299

@@ -1725,7 +1726,7 @@ class EventSourceHandler(BaseLambdaHandler):
17251726

17261727
def __init__(
17271728
self, func: Callable[..., Any], event_class: Any,
1728-
middleware_handlers: List[Callable[..., Any]] = None
1729+
middleware_handlers: Optional[List[Callable[..., Any]]] = None
17291730
) -> None:
17301731
self.func: Callable[..., Any] = func
17311732
self.event_class: Any = event_class

0 commit comments

Comments
 (0)