Skip to content

Avoid mutable default arguments #342

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 1 commit into from
Dec 16, 2021
Merged

Avoid mutable default arguments #342

merged 1 commit into from
Dec 16, 2021

Conversation

DimitriPapadopoulos
Copy link
Contributor

While they are not always an actual bug, they are certainly a Python anti-pattern and possible the source of future bugs.

In at least one case, the default mutable argument config is actually modified later on by the function.

See for example Python Mutable Defaults Are The Source of All Evil.

While they are not always an actual bug, they are certainly a Python
anti-pattern and possible the source of future bugs.

In at least one case, the default mutable argument `config` is actually
modified later on by the function.
Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Looks straightforward, will merge once CIs run and come back green

@larsoner larsoner merged commit 31aa19a into numpy:main Dec 16, 2021
@larsoner
Copy link
Collaborator

Thanks @DimitriPapadopoulos !

@DimitriPapadopoulos DimitriPapadopoulos deleted the mutable_defaults branch December 16, 2021 15:51
@jarrodmillman jarrodmillman added this to the 1.2.0 milestone Jan 9, 2022
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.

3 participants