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

Add IntEnum (like the standard library's IntEnum) #53

Merged
merged 1 commit into from
Jun 16, 2016
Merged

Conversation

akx
Copy link
Contributor

@akx akx commented Jun 16, 2016

No description provided.

@@ -26,4 +26,5 @@ def test_bound_form_with_instance():

def test_choices():
form = get_form()
assert form.base_fields["zero2"].choices == [(0, 'ZERO'), (1, 'ONE')]
assert form.base_fields["zero2"].choices == [(0, 'Zero'), (1, 'One')]
assert form.base_fields["int_enum"].choices == BLANK_CHOICE_DASH + [(0, 'foo'), (1, 'B')]
Copy link
Contributor

Choose a reason for hiding this comment

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

So, is this backward incompatible change, since the code for zero2 stays the same but still the choices change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No – the code for zero2 actually does change, albeit in a subtle way :)

IntEnum used to be imported directly from the stdlib.

However, now we're using our fancier IntEnum, which as the same choices behavior as enumfields.Enum, i.e. auto-titling the name for a choice label when no explicit label exists.

Before:

from enum import Enum, IntEnum

After:

from enumfields import Enum, IntEnum, EnumField, EnumIntegerField

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. I didn't notice that this import change was actually in tests/models.py. Yep. This is all good then.

@suutari-ai
Copy link
Contributor

LGTM

@akx akx merged commit bc07b8f into hzdg:master Jun 16, 2016
@akx akx deleted the int-enum branch June 16, 2016 07:56
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.

None yet

2 participants