Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion stdlib/2/_io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ class _IOBase(BinaryIO):
def writelines(self, lines: Iterable[bytes]) -> None: ...
# The return type of readline[s]() and next() is determined by that of read():
def readline(self, limit: int = ...) -> bytes: ...
def readlines(self, hint: int = ...) -> list[bytes]: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def next(self) -> bytes: ...
# These don't actually exist but we need to pretend that it does
# so that this class is concrete.
def write(self, s: bytes) -> int: ...
def read(self, n: int = ...) -> bytes: ...

class _BufferedIOBase(_IOBase):
def read1(self, n: int) -> bytes: ...
Expand Down
9 changes: 4 additions & 5 deletions stdlib/2/multiprocessing/pool.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Stubs for multiprocessing.pool (Python 2)

from typing import (
Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List,
TypeVar,
Any, Callable, ContextManager, Iterable, Optional, Dict, List,
TypeVar, Iterator,
)

_T = TypeVar('_T', bound='Pool')
_T = TypeVar('_T', bound=Pool)

class AsyncResult():
def get(self, timeout: Optional[float] = ...) -> Any: ...
Expand All @@ -14,6 +12,7 @@ class AsyncResult():
def successful(self) -> bool: ...

class IMapIterator(Iterable[Any]):
def __iter__(self) -> Iterator[Any]: ...
def next(self, timeout: Optional[float] = ...) -> Any: ...

class Pool(ContextManager[Pool]):
Expand Down
5 changes: 5 additions & 0 deletions stdlib/2/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ X_OK: int

class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
def copy(self) -> Dict[AnyStr, AnyStr]: ...
def __delitem__(self, key: AnyStr) -> None: ...
def __getitem__(self, key: AnyStr) -> AnyStr: ...
def __setitem__(self, key: AnyStr, value: AnyStr) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def __len__(self) -> int: ...

environ: _Environ[str]
if sys.version_info >= (3, 2):
Expand Down
59 changes: 33 additions & 26 deletions stdlib/2/tempfile.pyi
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
# Stubs for tempfile
# Ron Murawski <[email protected]>

# based on http: //docs.python.org/3.3/library/tempfile.html
# Adapted for Python 2.7 by Michal Pokorny

# TODO: Don't use basestring. Use Union[str, bytes] or AnyStr for arguments.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these TODOs still applies: the file contains no mention of basestring and no Union return types.

# Avoid using Union[str, bytes] for return values, as it implies that
# an isinstance() check will often be required, which is inconvenient.

from typing import Tuple, IO, Union, AnyStr, Any, overload, Iterator, List, Type, Optional

import thread
import random

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two imports are actually used below. I would actually write them as from random import Random and from thread import LockType.

from typing import Tuple, IO, Union, AnyStr, Any, overload, Iterator, List, Iterable, Optional
from thread import LockType
from random import Random

TMP_MAX = ... # type: int
tempdir = ... # type: str
template = ... # type: str
_name_sequence = ... # type: Optional[_RandomNameSequence]

class _RandomNameSequence:
_rng = ... # type: random.Random
_rng_pid = ... # type: int
characters = ... # type: str
mutex = ... # type: thread.LockType
rng = ... # type: random.Random
def __iter__(self) -> "_RandomNameSequence": ...
characters: str = ...
mutex: LockType
@property
def rng(self) -> Random: ...
def __iter__(self) -> _RandomNameSequence: ...
def next(self) -> str: ...
# from os.path:
def normcase(self, path: AnyStr) -> AnyStr: ...

class _TemporaryFileWrapper(IO[str]):
close_called = ... # type: bool

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute doesn't actually exist on _TemporaryFileWrapper.

delete = ... # type: bool
file = ... # type: IO
name = ... # type: Any
def __init__(self, file: IO, name, delete: bool = ...) -> None: ...
delete: bool
file: IO
name: Any
def __init__(self, file: IO, name: Any, delete: bool = ...) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> "_TemporaryFileWrapper": ...
def __enter__(self) -> _TemporaryFileWrapper: ...
def __exit__(self, exc, value, tb) -> bool: ...
def __getattr__(self, name: unicode) -> Any: ...
def close(self) -> None: ...
def unlink(self, path: unicode) -> None: ...
# These methods don't exist directly on this object, but
# are delegated to the underlying IO object through __getattr__.
# We need to add them here so that this class is concrete.
def __iter__(self) -> Iterator[str]: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def next(self) -> str: ...
def read(self, n: int = ...) -> str: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: str) -> int: ...
def writelines(self, lines: Iterable[str]) -> None: ...


# TODO text files

Expand Down
5 changes: 4 additions & 1 deletion stdlib/2and3/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class Dialect:
class _reader(Iterator[List[str]]):
dialect = ... # type: Dialect
line_num = ... # type: int
def __next__(self) -> List[str]: ...
if sys.version_info >= (3, 0):
def __next__(self) -> List[str]: ...
else:
def next(self) -> List[str]: ...

class _writer:
dialect = ... # type: Dialect
Expand Down
5 changes: 4 additions & 1 deletion stdlib/2and3/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class Cursor(Iterator[Any]):
def setinputsizes(self, *args, **kwargs): ...
def setoutputsize(self, *args, **kwargs): ...
def __iter__(self) -> Cursor: ...
def __next__(self) -> Any: ...
if sys.version_info >= (3, 0):
def __next__(self) -> Any: ...
else:
def next(self) -> Any: ...


class DataError(DatabaseError): ...
Expand Down