Skip to content

Add missing replace dunders #12265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__
Expand Down
11 changes: 8 additions & 3 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -266,7 +266,7 @@ class CodeType:
co_filename: str = ...,
co_name: str = ...,
co_linetable: bytes = ...,
) -> CodeType: ...
) -> Self: ...
else:
def replace(
self,
Expand All @@ -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]):
Expand All @@ -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
Expand Down
Loading