Skip to content

Commit 8150b51

Browse files
Sync typeshed (#17988)
Source commit: python/typeshed@559ae97
1 parent 5d9b1f9 commit 8150b51

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
3-
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
3+
from collections.abc import Awaitable, Callable, Coroutine, Generator
44
from contextvars import Context
55
from types import FrameType
66
from typing import Any, Literal, TextIO, TypeVar
@@ -13,7 +13,7 @@ _T = TypeVar("_T")
1313
_T_co = TypeVar("_T_co", covariant=True)
1414
_TaskYieldType: TypeAlias = Future[object] | None
1515

16-
class Future(Awaitable[_T], Iterable[_T]):
16+
class Future(Awaitable[_T]):
1717
_state: str
1818
@property
1919
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/_csv.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import csv
12
import sys
23
from _typeshed import SupportsWrite
34
from collections.abc import Iterable, Iterator
@@ -20,7 +21,7 @@ _QuotingType: TypeAlias = int
2021

2122
class Error(Exception): ...
2223

23-
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
24+
_DialectLike: TypeAlias = str | Dialect | csv.Dialect | type[Dialect | csv.Dialect]
2425

2526
class Dialect:
2627
delimiter: str

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,10 @@ class slice:
850850
@overload
851851
def __new__(cls, start: Any, stop: Any, step: Any = ..., /) -> Self: ...
852852
def __eq__(self, value: object, /) -> bool: ...
853-
__hash__: ClassVar[None] # type: ignore[assignment]
853+
if sys.version_info >= (3, 12):
854+
def __hash__(self) -> int: ...
855+
else:
856+
__hash__: ClassVar[None] # type: ignore[assignment]
854857
def indices(self, len: SupportsIndex, /) -> tuple[int, int, int]: ...
855858

856859
class tuple(Sequence[_T_co]):

mypy/typeshed/stdlib/csv.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from _csv import (
44
QUOTE_MINIMAL as QUOTE_MINIMAL,
55
QUOTE_NONE as QUOTE_NONE,
66
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
7-
Dialect as _Dialect,
87
Error as Error,
98
__version__ as __version__,
109
_DialectLike,
@@ -59,7 +58,15 @@ if sys.version_info < (3, 13):
5958

6059
_T = TypeVar("_T")
6160

62-
class Dialect(_Dialect):
61+
class Dialect:
62+
delimiter: str
63+
quotechar: str | None
64+
escapechar: str | None
65+
doublequote: bool
66+
skipinitialspace: bool
67+
lineterminator: str
68+
quoting: _QuotingType
69+
strict: bool
6370
def __init__(self) -> None: ...
6471

6572
class excel(Dialect): ...

mypy/typeshed/stdlib/posixpath.pyi

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ pathsep: LiteralString
7777
defpath: LiteralString
7878
devnull: LiteralString
7979

80-
def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
80+
# Overloads are necessary to work around python/mypy#17952 & python/mypy#11880
81+
@overload
82+
def abspath(path: PathLike[AnyStr]) -> AnyStr: ...
83+
@overload
84+
def abspath(path: AnyStr) -> AnyStr: ...
8185
@overload
8286
def basename(p: PathLike[AnyStr]) -> AnyStr: ...
8387
@overload
@@ -86,8 +90,14 @@ def basename(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
8690
def dirname(p: PathLike[AnyStr]) -> AnyStr: ...
8791
@overload
8892
def dirname(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
89-
def expanduser(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
90-
def expandvars(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
93+
@overload
94+
def expanduser(path: PathLike[AnyStr]) -> AnyStr: ...
95+
@overload
96+
def expanduser(path: AnyStr) -> AnyStr: ...
97+
@overload
98+
def expandvars(path: PathLike[AnyStr]) -> AnyStr: ...
99+
@overload
100+
def expandvars(path: AnyStr) -> AnyStr: ...
91101
@overload
92102
def normcase(s: PathLike[AnyStr]) -> AnyStr: ...
93103
@overload

mypy/typeshed/stdlib/unittest/runner.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ class _SupportsWriteAndFlush(SupportsWrite[str], SupportsFlush, Protocol): ...
1313

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

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

0 commit comments

Comments
 (0)