Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy (#1421)

* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
This commit is contained in:
Guido van Rossum
2017-06-20 22:18:49 -07:00
committed by Jelle Zijlstra
parent 30256097ea
commit 04fe184dcf
23 changed files with 257 additions and 237 deletions

View File

@@ -2,7 +2,7 @@ from abc import abstractmethod
import asyncore
import socket
import sys
from typing import Union, Tuple, Sequence
from typing import Optional, Sequence, Tuple, Union
class simple_producer:
@@ -12,7 +12,7 @@ class simple_producer:
class async_chat(asyncore.dispatcher):
ac_in_buffer_size = ... # type: int
ac_out_buffer_size = ... # type: int
def __init__(self, sock: socket.socket = None, map: asyncore._maptype = None) -> None: ...
def __init__(self, sock: Optional[socket.socket] = None, map: Optional[asyncore._maptype] = None) -> None: ...
@abstractmethod
def collect_incoming_data(self, data: bytes) -> None: ...

View File

@@ -25,7 +25,7 @@ def poll2(timeout: float = ..., map: _maptype = ...) -> None: ...
poll3 = poll2
def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: int = None) -> None: ...
def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: Optional[int] = None) -> None: ...
# Not really subclass of socket.socket; it's only delegation.
@@ -39,7 +39,7 @@ class dispatcher:
closing = ... # type: bool
ignore_log_types = ... # type: frozenset[str]
def __init__(self, sock: socket.socket = None, map: _maptype = ...) -> None: ...
def __init__(self, sock: Optional[socket.socket] = None, map: _maptype = ...) -> None: ...
def add_channel(self, map: _maptype = ...) -> None: ...
def del_channel(self, map: _maptype = ...) -> None: ...
def create_socket(self, family: int, type: int) -> None: ...

View File

@@ -1,21 +1,21 @@
# Stubs for bz2
from typing import Any, BinaryIO, TextIO, IO, Union
from typing import Any, BinaryIO, TextIO, IO, Optional, Union
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...
def open(filename: Union[str, bytes, IO[Any]],
mode: str = 'rb',
encoding: str = None,
errors: str = None,
newline: str = None) -> IO[Any]: ...
encoding: Optional[str] = None,
errors: Optional[str] = None,
newline: Optional[str] = None) -> IO[Any]: ...
class BZ2File(BinaryIO):
def __init__(self,
filename: Union[str, bytes, IO[Any]],
mode: str = "r",
buffering: Any = None,
buffering: Optional[Any] = None,
compresslevel: int = 9) -> None: ...
class BZ2Compressor(object):

View File

@@ -1,15 +1,15 @@
# NOTE: This stub is incomplete - only contains some global functions
from typing import Any, Dict
from typing import Any, Dict, Optional
def run(statement: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> None:
globals: Optional[Dict[str, Any]] = None,
locals: Optional[Dict[str, Any]] = None) -> None:
...
def runeval(expression: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> Any:
globals: Optional[Dict[str, Any]] = None,
locals: Optional[Dict[str, Any]] = None) -> Any:
...
def runctx(statement: str,
@@ -23,7 +23,7 @@ def runcall(*args: Any, **kwds: Any) -> Any:
def set_trace() -> None:
...
def post_mortem(t: Any = None) -> None:
def post_mortem(t: Optional[Any] = None) -> None:
...
def pm() -> None: