From 0d2b9dfe123f0104823a4574a84199a288a78b23 Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Wed, 3 Jul 2024 22:30:22 -0500 Subject: [PATCH] Add missing replace dunders (#12265) --- stdlib/@tests/stubtest_allowlists/py313.txt | 3 +-- stdlib/types.pyi | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index c507f44f2..ca3b2df71 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -116,6 +116,7 @@ pdb.Pdb.do_exceptions pdb.Pdb.interaction pdb.Pdb.message pdb.Pdb.user_opcode +# `__replace__` to be special cased in dataclasses pstats.FunctionProfile.__replace__ pstats.StatsProfile.__replace__ pydoc.pager @@ -156,9 +157,7 @@ tkinter.PhotoImage.zoom tkinter.Text.count tkinter.Wm.wm_attributes trace.CoverageResults.write_results -types.CodeType.__replace__ types.MappingProxyType.get -types.SimpleNamespace.__replace__ unittest.IsolatedAsyncioTestCase.loop_factory unittest.TestProgram.usageExit unittest.__all__ diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 9e9dc56b8..df2d853a6 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -245,7 +245,7 @@ class CodeType: co_qualname: str = ..., co_linetable: bytes = ..., co_exceptiontable: bytes = ..., - ) -> CodeType: ... + ) -> Self: ... elif sys.version_info >= (3, 10): def replace( self, @@ -266,7 +266,7 @@ class CodeType: co_filename: str = ..., co_name: str = ..., co_linetable: bytes = ..., - ) -> CodeType: ... + ) -> Self: ... else: def replace( self, @@ -287,7 +287,10 @@ class CodeType: co_filename: str = ..., co_name: str = ..., co_lnotab: bytes = ..., - ) -> CodeType: ... + ) -> Self: ... + + if sys.version_info >= (3, 13): + __replace__ = replace @final class MappingProxyType(Mapping[_KT, _VT_co]): @@ -314,6 +317,8 @@ class SimpleNamespace: def __getattribute__(self, name: str, /) -> Any: ... def __setattr__(self, name: str, value: Any, /) -> None: ... def __delattr__(self, name: str, /) -> None: ... + if sys.version_info >= (3, 13): + def __replace__(self, **kwargs: Any) -> Self: ... class ModuleType: __name__: str