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

Issue 4: sparse declarative defaults #5

Merged
merged 5 commits into from
Sep 16, 2017
Merged

Issue 4: sparse declarative defaults #5

merged 5 commits into from
Sep 16, 2017

Conversation

TadLeonard
Copy link
Owner

Declarative defaults now handle sparseness

A fix for #4. The old way of setting SparseEnumap defaults (SparseEnumap.set_defaults(...)) handled sparseness correctly. That is, calling set_defaults(*args, **kwargs) created a defaults dictionary with None placeholders. For example:

class People(SparseEnumap):
    donald = auto()
    vladimir = auto()
    william = auto

People.set_defaults(donald=1, william=5)
People.defaults()   # {"donald": 1, "vladimir": None, "william": 5}

The declarative version:

class People(SparseEnumap):
    donald = auto()
    vladimir = auto()
    william = auto

People.defaults()   # {"donald": 1, "william": 5}

... was broken. Each member in a SparseEnumap should have a default no matter what.

Copy link

@jonemo jonemo left a comment

Choose a reason for hiding this comment

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

lgtm

@TadLeonard
Copy link
Owner Author

Thanks, @jonemo. Merging so that tests with sparse types for PR #3 can be written.

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