Add Optional[] for all remaining cases of x: <type> = None (#1424)

* Final round of adding Optional[] to type of arguments with default = None
* Update Travis to use --no-implicit-optionals and clarify CONTRIBUTING.md
This commit is contained in:
Guido van Rossum
2017-06-21 10:50:21 -07:00
committed by Matthias Kramm
parent 81f77b17ec
commit 350563223f
18 changed files with 152 additions and 133 deletions

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Callable, Dict, List, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple
if sys.version_info >= (3, 5):
class JSONDecodeError(ValueError):
@@ -18,11 +18,11 @@ class JSONDecoder:
strict = ... # type: bool
object_pairs_hook = None # type: Callable[[List[Tuple[str, Any]]], Any]
def __init__(self, object_hook: Callable[[Dict[str, Any]], Any]=None,
parse_float: Callable[[str], Any]=None,
parse_int: Callable[[str], Any]=None,
parse_constant: Callable[[str], Any]=None,
strict: bool=True,
object_pairs_hook: Callable[[List[Tuple[str, Any]]], Any]=None) -> None: ...
def __init__(self, object_hook: Optional[Callable[[Dict[str, Any]], Any]] = None,
parse_float: Optional[Callable[[str], Any]] = None,
parse_int: Optional[Callable[[str], Any]] = None,
parse_constant: Optional[Callable[[str], Any]] = None,
strict: bool = True,
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = None) -> None: ...
def decode(self, s: str) -> Any: ...
def raw_decode(self, s: str, idx: int=...) -> Tuple[Any, int]: ...
def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Iterator, Tuple
from typing import Any, Callable, Iterator, Optional, Tuple
class JSONEncoder:
item_separator = ... # type: str
@@ -11,10 +11,10 @@ class JSONEncoder:
sort_keys = ... # type: bool
indent = None # type: int
def __init__(self, skipkeys: bool=..., ensure_ascii: bool=...,
check_circular: bool=..., allow_nan: bool=..., sort_keys: bool=...,
indent: int=None, separators: Tuple[str, str]=None, default: Callable=None) -> None: ...
def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ...,
check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ...,
indent: Optional[int] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None) -> None: ...
def default(self, o: Any) -> Any: ...
def encode(self, o: Any) -> str: ...
def iterencode(self, o: Any, _one_shot: bool=False) -> Iterator[str]: ...
def iterencode(self, o: Any, _one_shot: bool = False) -> Iterator[str]: ...