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
33 changes: 33 additions & 0 deletions stdlib/3/tempfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,39 @@ else:
dir: Optional[_DirT[AnyStr]] = ...,
) -> IO[Any]: ...

class _TemporaryFileWrapper(IO[str]):
file: IO[str]
name: Any
delete: bool
def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ...
def __enter__(self) -> _TemporaryFileWrapper: ...
def __exit__(
self, exc: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType]
) -> Optional[bool]: ...
def __getattr__(self, name: str) -> Any: ...
def close(self) -> None: ...
def unlink(self, path: str) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does this come from? As far as I can see, it's not defined in _TemporaryFileWrapper, so shouldn't it be below the next comment?

# 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 __next__(self) -> 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: ...

# It does not actually derive from IO[AnyStr], but it does implement the
# protocol.
class SpooledTemporaryFile(IO[AnyStr]):
Expand Down
2 changes: 2 additions & 0 deletions tests/stubtest_whitelists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ builtins.quit
builtins.reveal_locals
builtins.reveal_type
collections.abc.* # Types are re-exported from _collections_abc, so errors should be fixed there
# Dynamically specified by __getattr__, and thus don't exist on the class
tempfile._TemporaryFileWrapper.[\w_]+
# Various classes in typing aren't types at runtime. In addition, mypy thinks some special forms are tautologically defined.
typing.[A-Z]\w+
# We can't distinguish not having a default value from having a default value of inspect.Parameter.empty
Expand Down