Skip to content
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

Modifies sentence and provides link to explanation of mutable defaults gotcha in the documentation #1251

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

mikejturner
Copy link
Contributor

Summary

Modifies existing sentence and provides link to an explanation of the common gotcha of mutable default parameters for functions/methods. The change occurs on the "Initialization" page (init.html/init.md) of the documentation.

The change adds a link is to this section on python-guide.org. I have no connection to python-guide.org — I just like their explanation and would be happy to change it, if you have a better replacement in mind.

Justification

The documentation already states that mutable default arguments (probably) don't work as expected and alludes to similar gotcha with function/method parameters. I think it could be helpful to provide link to an simple explanation to understand the connection the two situations.

There are many other precedents in the documentation for providing helpful links, for example, "Subclassing considered bad" and "think twice before using pickle"... and this is something that makes me really appreciate attrs documentation.

Pull Request Check List

Copy link
Member

@hynek hynek left a comment

Choose a reason for hiding this comment

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

I'm not sure how I feel about python-guide but that explanation seems good – thanks!

@hynek hynek added this pull request to the merge queue Feb 29, 2024
Merged via the queue into python-attrs:main with commit 69b6626 Feb 29, 2024
20 checks passed
@mikejturner mikejturner deleted the add_mutable_default_link branch February 29, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants