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 enum support #14

Open
lamenezes opened this issue Jun 23, 2019 · 0 comments
Open

add enum support #14

lamenezes opened this issue Jun 23, 2019 · 0 comments

Comments

@lamenezes
Copy link
Owner

lamenezes commented Jun 23, 2019

not sure how this would look, but I can see people that already use enums for "status handling" (or similar stuff) wanting the features status map provides.

we might tackle this with a enum-like interface:

from status_map.enum import StatusEnum  # this should be compatible with std lib's enum.Enum


class TaskEnum(StatusEnum):
    TODO = 0  # there might be a better way to do this in the std lib
    DOING = 1
    DONE = 2

The issue here is: how do we handle the transitions having an interface like that?

We might appeal to a django-like Meta class (I'm not really a fan of it though):

class TaskEnum(StatusEnum):
    TODO = 0
    DOING = 1
    DONE = 2

    class Meta:
        transitions = {'TODO': ['DOING'], 'DOING': ['TODO', 'DONE'], 'DONE': []}

Another possibility is to bet on a more of a "freestyle" method:

class TaskEnum(StatusEnum):
    TODO = 0, 'task waiting for someone work on it', ['DOING']
    DOING = 1, 'task in progess', ['TODO', 'DONE"]
    DONE = 2, 'task ready!', []  # adding the possibility to the user describe what each status means

It's not very intuitive but at the same time not complicated. With this approach I think we save a lot of code and can even add some meaning to all this. And it's not too difficult to implement if we use the aenum [1] lib.

Those two were the best alternatives I could think of, but there might be better ideas.

[1] https://bitbucket.org/stoneleaf/aenum/

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

No branches or pull requests

1 participant