Closed jayvdb closed 4 years ago
Where it changes in Django https://github.com/django/django/commit/c1aec0feda7
I hit this one quite often; e.g. https://github.com/willandskill/django-executor/pull/1#discussion_r429519195 https://github.com/andrewyoung1991/django-restframework-stripe/pull/2#discussion_r425979305
Hm indeed, I had skip this one as "particularly hard", but now that I think about it, maybe returning a custom class instance, with proper bool and call methods, would do it?
But then comparisons with other values must be handled too...
I have to think a bit more, surely there will be a need for subclassing builtin type "bool" - https://jfine-python-classes.readthedocs.io/en/latest/subclass-int.html
It looks doable, although I know from numerous people who tried, that it's always a hazardous path ^^
https://github.com/clarete/forbiddenfruit is getting quite good.
https://github.com/aalekseev/healthy-projects/tree/master/src/django_patches/user_is_authenticated (code patcher, it seems)
OK I've added a fixer for this, restauring their old "CallableBool" class - it's all in master branch. Please let me know if related problems are not solved by this.
I don't know why it doesn't just work by subclassing "int", but I'd better stay close to the original shim implementation B-) ForbiddenFruit and the likes seem powerful, but it's safer to stay compatible with all Python implementations I guess.
It became a property circa 1.9/1.10