mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Add more methods to return type of tempfile.{,Named,Spooled}TemporaryFile(). (#623)
This commit is contained in:
committed by
Guido van Rossum
parent
df6aeef9fd
commit
3253d3cc46
@@ -8,10 +8,41 @@
|
||||
# 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
|
||||
from typing import Tuple, IO, Union, AnyStr, Any, overload, Iterator, List, Type, Optional
|
||||
|
||||
import thread
|
||||
import random
|
||||
|
||||
TMP_MAX = ... # type: int
|
||||
tempdir = ... # type: str
|
||||
template = ... # type: str
|
||||
_name_sequence = ... # type: Optional[_RandomNameSequence]
|
||||
|
||||
class _RandomNameSequence:
|
||||
__doc__ = ... # type: str
|
||||
_rng = ... # type: random.Random
|
||||
_rng_pid = ... # type: int
|
||||
characters = ... # type: str
|
||||
mutex = ... # type: thread.LockType
|
||||
rng = ... # type: random.Random
|
||||
def __iter__(self) -> "_RandomNameSequence": ...
|
||||
def next(self) -> str: ...
|
||||
# from os.path:
|
||||
def normcase(path: AnyStr) -> AnyStr: ...
|
||||
|
||||
class _TemporaryFileWrapper(IO[str]):
|
||||
__doc__ = ... # type: str
|
||||
close_called = ... # type: bool
|
||||
delete = ... # type: bool
|
||||
file = ... # type: IO
|
||||
name = ... # type: Any
|
||||
def __init__(self, file: IO, name, delete:bool = ...) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> "_TemporaryFileWrapper": ...
|
||||
def __exit__(self, exc, value, tb) -> bool: ...
|
||||
def __getattr__(self, name: unicode) -> Any: ...
|
||||
def close(self) -> None: ...
|
||||
def unlink(path: unicode) -> None: ...
|
||||
|
||||
# TODO text files
|
||||
|
||||
@@ -20,7 +51,7 @@ def TemporaryFile(
|
||||
bufsize: int = ...,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...) -> IO[str]: ...
|
||||
dir: Union[bytes, unicode] = ...) -> _TemporaryFileWrapper: ...
|
||||
def NamedTemporaryFile(
|
||||
mode: Union[bytes, unicode] = ...,
|
||||
bufsize: int = ...,
|
||||
@@ -28,14 +59,14 @@ def NamedTemporaryFile(
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...,
|
||||
delete: bool = ...
|
||||
) -> IO[str]: ...
|
||||
) -> _TemporaryFileWrapper: ...
|
||||
def SpooledTemporaryFile(
|
||||
max_size: int = ...,
|
||||
mode: Union[bytes, unicode] = ...,
|
||||
buffering: int = ...,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...) -> IO[str]:
|
||||
dir: Union[bytes, unicode] = ...) -> _TemporaryFileWrapper:
|
||||
...
|
||||
|
||||
class TemporaryDirectory:
|
||||
@@ -63,3 +94,7 @@ def mktemp() -> str: ...
|
||||
def mktemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr = ...) -> AnyStr: ...
|
||||
def gettempdir() -> str: ...
|
||||
def gettempprefix() -> str: ...
|
||||
|
||||
def _candidate_tempdir_list() -> List[str]: ...
|
||||
def _get_candidate_names() -> Optional[_RandomNameSequence]: ...
|
||||
def _get_default_tempdir() -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user