Skip to content

gh-117764: Add docstrings and signatures for the __replace__ methods #117768

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 2 commits into from
Apr 12, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 11, 2024

{"__replace__", _PyCFunction_CAST(namespace_replace), METH_VARARGS|METH_KEYWORDS, NULL},
{"__replace__", _PyCFunction_CAST(namespace_replace), METH_VARARGS|METH_KEYWORDS,
PyDoc_STR("__replace__($self, **changes)\n--\n\n"
"Return a copy of the namespace object with new values for the specified attributes.")},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this docstring uses the term attributes, but all the others in this PR use the term fields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because SimpleNamespace is described as "a simple attribute-based namespace". code.replace() talk about fields (I copied the docstring for __replace__()). Also, the set of fields is limited for all other objects, you cannot set an arbitrary attribute.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) April 12, 2024 08:21
@serhiy-storchaka serhiy-storchaka merged commit 6e05537 into python:main Apr 12, 2024
34 checks passed
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants