Misc fixes found by running mypy against Dropbox internal codebase "C". (#1575)

This commit is contained in:
Guido van Rossum
2017-08-25 20:34:13 -07:00
committed by Jelle Zijlstra
parent 1050b383a3
commit 76685480e0
4 changed files with 15 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
from builtins import OSError as error
from io import TextIOWrapper as _TextIOWrapper
from posix import stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078
import sys
from typing import (
Mapping, MutableMapping, Dict, List, Any, Tuple, Iterator, overload, Union, AnyStr,
@@ -126,6 +127,7 @@ _StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_bloc
('f_bfree', int), ('f_bavail', int), ('f_files', int),
('f_ffree', int), ('f_favail', int), ('f_flag', int),
('f_namemax', int)])
def ctermid() -> str: ... # Unix only
def getegid() -> int: ... # Unix only
def geteuid() -> int: ... # Unix only

View File

@@ -1,6 +1,6 @@
# Stubs for traceback
from typing import Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type
from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type
from types import FrameType, TracebackType
import sys
@@ -92,10 +92,19 @@ if sys.version_info >= (3, 5):
if sys.version_info >= (3, 5):
class FrameSummary:
filename: str
lineno: int
name: str
line: str
locals: Optional[Dict[str, str]]
def __init__(self, filename: str, lineno: int, name: str,
lookup_line: bool = ...,
locals: Optional[Mapping[str, str]] = ...,
line: Optional[int] = ...) -> None: ...
# TODO: more precise typing for __getitem__ and __iter__,
# for a namedtuple-like view on (filename, lineno, name, str).
def __getitem__(self, i: int) -> Any: ...
def __iter__(self) -> Iterator[Any]: ...
class StackSummary(List[FrameSummary]):
@classmethod
@@ -105,3 +114,4 @@ if sys.version_info >= (3, 5):
capture_locals: bool = ...) -> StackSummary: ...
@classmethod
def from_list(cls, a_list: List[_PT]) -> StackSummary: ...
def format(self) -> List[str]: ...

View File

@@ -50,7 +50,7 @@ class object:
def __sizeof__(self) -> int: ...
def __reduce__(self) -> tuple: ...
def __reduce_ex__(self, protocol: int) -> tuple: ...
def __dir__(self) -> List[str]: ...
def __dir__(self) -> Iterable[str]: ...
if sys.version_info >= (3, 6):
def __init_subclass__(cls) -> None: ...

View File

@@ -11,7 +11,7 @@ from types import ModuleType, TracebackType
_T = TypeVar('_T')
_FT = TypeVar('_FT', bound=Callable[[Any], Any])
_FT = TypeVar('_FT', bound=Callable[..., Any])
_E = TypeVar('_E', bound=Exception)