pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.52k stars 525 forks source link

Fix transitions for enums with str behavior (Django3) #386

Closed artofhuman closed 4 years ago

artofhuman commented 4 years ago

Django3 introduced enums (TextChoices), but this enums has str behavior see https://github.com/django/django/blob/master/django/db/models/enums.py#L77

isinstance(source, string_types) returns True

To avoid this behavior, we need to remove the check on str class.

aleneum commented 4 years ago

Hi @artofhuman,

since this line should take care of the single string case I don't see any drawback. Quite the contrary, it looks cleaner now. Thanks for the PR! Have some nice holidays and a good start into 2020!

artofhuman commented 4 years ago

@aleneum Thanks 🎄

artofhuman commented 4 years ago

Hi @aleneum, can we release this commit in new patch version 0.7.2 ?I tested in our project and my tests are green :)