Skip to content

Commit

Permalink
tempfile: Fix TypeVar usage (#7939)
Browse files Browse the repository at this point in the history
Co-authored-by: Jelle Zijlstra <[email protected]>
  • Loading branch information
AlexWaygood and JelleZijlstra authored May 26, 2022
1 parent c8f9abf commit cb7742e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions stdlib/tempfile.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io
import os
import sys
from _typeshed import Self, WriteableBuffer
from _typeshed import Self, StrPath, WriteableBuffer
from collections.abc import Iterable, Iterator
from types import TracebackType
from typing import IO, Any, AnyStr, Generic, overload
Expand Down Expand Up @@ -380,20 +380,22 @@ class TemporaryDirectory(Generic[AnyStr]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

# The overloads overlap, but they should still work fine.
@overload
def mkstemp() -> tuple[int, str]: ...
def mkstemp( # type: ignore[misc]
suffix: str | None = ..., prefix: str | None = ..., dir: _DirT[str] | None = ..., text: bool = ...
) -> tuple[int, str]: ...
@overload
def mkstemp(
suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ..., text: bool = ...
) -> tuple[int, AnyStr]: ...
@overload
def mkdtemp() -> str: ...
@overload
def mkdtemp(suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ...) -> AnyStr: ...
suffix: bytes | None = ..., prefix: bytes | None = ..., dir: _DirT[bytes] | None = ..., text: bool = ...
) -> tuple[int, bytes]: ...

# The overloads overlap, but they should still work fine.
@overload
def mktemp() -> str: ...
def mkdtemp(suffix: str | None = ..., prefix: str | None = ..., dir: _DirT[str] | None = ...) -> str: ... # type: ignore[misc]
@overload
def mktemp(suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: _DirT[AnyStr] | None = ...) -> AnyStr: ...
def mkdtemp(suffix: bytes | None = ..., prefix: bytes | None = ..., dir: _DirT[bytes] | None = ...) -> bytes: ...
def mktemp(suffix: str = ..., prefix: str = ..., dir: StrPath | None = ...) -> str: ...
def gettempdirb() -> bytes: ...
def gettempprefixb() -> bytes: ...
def gettempdir() -> str: ...
Expand Down

0 comments on commit cb7742e

Please sign in to comment.