Skip to content

Commit

Permalink
Sync typeshed (#17988)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 18, 2024
1 parent 5d9b1f9 commit 8150b51
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_asyncio.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
from collections.abc import Awaitable, Callable, Coroutine, Generator
from contextvars import Context
from types import FrameType
from typing import Any, Literal, TextIO, TypeVar
Expand All @@ -13,7 +13,7 @@ _T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_TaskYieldType: TypeAlias = Future[object] | None

class Future(Awaitable[_T], Iterable[_T]):
class Future(Awaitable[_T]):
_state: str
@property
def _exception(self) -> BaseException | None: ...
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import csv
import sys
from _typeshed import SupportsWrite
from collections.abc import Iterable, Iterator
Expand All @@ -20,7 +21,7 @@ _QuotingType: TypeAlias = int

class Error(Exception): ...

_DialectLike: TypeAlias = str | Dialect | type[Dialect]
_DialectLike: TypeAlias = str | Dialect | csv.Dialect | type[Dialect | csv.Dialect]

class Dialect:
delimiter: str
Expand Down
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,10 @@ class slice:
@overload
def __new__(cls, start: Any, stop: Any, step: Any = ..., /) -> Self: ...
def __eq__(self, value: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 12):
def __hash__(self) -> int: ...
else:
__hash__: ClassVar[None] # type: ignore[assignment]
def indices(self, len: SupportsIndex, /) -> tuple[int, int, int]: ...

class tuple(Sequence[_T_co]):
Expand Down
11 changes: 9 additions & 2 deletions mypy/typeshed/stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ from _csv import (
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Dialect as _Dialect,
Error as Error,
__version__ as __version__,
_DialectLike,
Expand Down Expand Up @@ -59,7 +58,15 @@ if sys.version_info < (3, 13):

_T = TypeVar("_T")

class Dialect(_Dialect):
class Dialect:
delimiter: str
quotechar: str | None
escapechar: str | None
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: _QuotingType
strict: bool
def __init__(self) -> None: ...

class excel(Dialect): ...
Expand Down
16 changes: 13 additions & 3 deletions mypy/typeshed/stdlib/posixpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ pathsep: LiteralString
defpath: LiteralString
devnull: LiteralString

def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
# Overloads are necessary to work around python/mypy#17952 & python/mypy#11880
@overload
def abspath(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def abspath(path: AnyStr) -> AnyStr: ...
@overload
def basename(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
Expand All @@ -86,8 +90,14 @@ def basename(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
def dirname(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
def dirname(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
def expanduser(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
def expandvars(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
@overload
def expanduser(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def expanduser(path: AnyStr) -> AnyStr: ...
@overload
def expandvars(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def expandvars(path: AnyStr) -> AnyStr: ...
@overload
def normcase(s: PathLike[AnyStr]) -> AnyStr: ...
@overload
Expand Down
3 changes: 2 additions & 1 deletion mypy/typeshed/stdlib/unittest/runner.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class _SupportsWriteAndFlush(SupportsWrite[str], SupportsFlush, Protocol): ...

# All methods used by unittest.runner.TextTestResult's stream
class _TextTestStream(_SupportsWriteAndFlush, Protocol):
def writeln(self, arg: str | None = None) -> str: ...
def writeln(self, arg: str | None = None, /) -> str: ...

# _WritelnDecorator should have all the same attrs as its stream param.
# But that's not feasible to do Generically
# We can expand the attributes if requested
class _WritelnDecorator(_TextTestStream):
def __init__(self, stream: _TextTestStream) -> None: ...
def writeln(self, arg: str | None = None) -> str: ...
def __getattr__(self, attr: str) -> Any: ... # Any attribute from the stream type passed to __init__
# These attributes are prevented by __getattr__
stream: Never
Expand Down

0 comments on commit 8150b51

Please sign in to comment.