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

Use attr.Factory for all "mutable" defaults #114

Merged
merged 1 commit into from
Feb 26, 2018
Merged

Use attr.Factory for all "mutable" defaults #114

merged 1 commit into from
Feb 26, 2018

Conversation

jml
Copy link
Contributor

@jml jml commented Feb 26, 2018

Fixes #105, preventing a class of unlikely by nasty bugs (see Python gotchas)

What does this do?

Ensures that any default attribute values which are of mutable type are constructed with attr.Factory, to prevent accidental re-use.

Why is it a good idea?

If someone does mutate these values (not recommended) they will see weird and hard-to-predict behaviour.

In practice, a lot of these defaults are immutable, but until we
actually freeze the data structures, we should code defensively.
Copy link
Contributor

@leth leth left a comment

Choose a reason for hiding this comment

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

LGTM

@jml jml merged commit cc7f04f into master Feb 26, 2018
@jml jml deleted the fix-defaults branch February 26, 2018 12:38
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