Skip to content

Commit 92eab7b

Browse files
Fix __new__ issues in 3.14 (#14626)
1 parent 8583419 commit 92eab7b

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

stdlib/_zstd.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class ZstdCompressor:
4545
CONTINUE: Final = 0
4646
FLUSH_BLOCK: Final = 1
4747
FLUSH_FRAME: Final = 2
48-
def __init__(
48+
def __new__(
4949
self, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None
50-
) -> None: ...
50+
) -> Self: ...
5151
def compress(
5252
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0
5353
) -> bytes: ...
@@ -58,7 +58,7 @@ class ZstdCompressor:
5858

5959
@final
6060
class ZstdDecompressor:
61-
def __init__(self, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> None: ...
61+
def __new__(self, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> Self: ...
6262
def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
6363
@property
6464
def eof(self) -> bool: ...
@@ -69,7 +69,7 @@ class ZstdDecompressor:
6969

7070
@final
7171
class ZstdDict:
72-
def __init__(self, dict_content: bytes, /, *, is_raw: bool = False) -> None: ...
72+
def __new__(self, dict_content: bytes, /, *, is_raw: bool = False) -> Self: ...
7373
def __len__(self, /) -> int: ...
7474
@property
7575
def as_digested_dict(self) -> tuple[Self, int]: ...

stdlib/functools.pyi

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,17 @@ class partialmethod(Generic[_T]):
169169
func: Callable[..., _T] | _Descriptor
170170
args: tuple[Any, ...]
171171
keywords: dict[str, Any]
172-
@overload
173-
def __init__(self, func: Callable[..., _T], /, *args: Any, **keywords: Any) -> None: ...
174-
@overload
175-
def __init__(self, func: _Descriptor, /, *args: Any, **keywords: Any) -> None: ...
172+
if sys.version_info >= (3, 14):
173+
@overload
174+
def __new__(self, func: Callable[..., _T], /, *args: Any, **keywords: Any) -> Self: ...
175+
@overload
176+
def __new__(self, func: _Descriptor, /, *args: Any, **keywords: Any) -> Self: ...
177+
else:
178+
@overload
179+
def __init__(self, func: Callable[..., _T], /, *args: Any, **keywords: Any) -> None: ...
180+
@overload
181+
def __init__(self, func: _Descriptor, /, *args: Any, **keywords: Any) -> None: ...
182+
176183
def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ...
177184
@property
178185
def __isabstractmethod__(self) -> bool: ...

stdlib/mmap.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PAGESIZE: Final[int]
3333

3434
class mmap:
3535
if sys.platform == "win32":
36-
def __init__(self, fileno: int, length: int, tagname: str | None = None, access: int = 0, offset: int = 0) -> None: ...
36+
def __new__(self, fileno: int, length: int, tagname: str | None = None, access: int = 0, offset: int = 0) -> Self: ...
3737
else:
3838
if sys.version_info >= (3, 13):
3939
def __new__(

0 commit comments

Comments
 (0)