Type fixes for tempfile.TemporaryDirectory (#5121)

If no arguments are passed to the TemporaryDirectory constructor, then
the class defaults to using str. Overload the __init__ function to
cover this case.
This commit is contained in:
Edgar Handal
2021-03-22 20:30:22 -05:00
committed by GitHub
parent 0ec182227c
commit 45c916e8d2

View File

@@ -310,7 +310,10 @@ class SpooledTemporaryFile(IO[AnyStr]):
def __next__(self) -> AnyStr: ...
class TemporaryDirectory(Generic[AnyStr]):
name: str
name: AnyStr
@overload
def __init__(self: TemporaryDirectory[str], suffix: None = ..., prefix: None = ..., dir: None = ...) -> None: ...
@overload
def __init__(
self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...
) -> None: ...