[Django] #29772: SimpleLazyObject doesn't implement __gt__ / __lt__

7 views
Skip to first unread message

Django

unread,
Sep 19, 2018, 7:22:25 AM9/19/18
to django-...@googlegroups.com
#29772: SimpleLazyObject doesn't implement __gt__ / __lt__
-----------------------------------------+------------------------
Reporter: Javier Buzzi | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Similar ticket: https://code.djangoproject.com/ticket/26287

I'm trying to implement this:

{{{
MinValueValidator(SimpleLazyObject(datetime.date.today))(datetime.date(2018,
9, 19))
}}}

The reason it doesn't work seems to be because `__lt__` and `__gt__` are
not implemented in `LazyObject`.

When i make the following change:


{{{
class Simple(SimpleLazyObject):
__lt__ = new_method_proxy(operator.lt)
__gt__ = new_method_proxy(operator.gt)

MinValueValidator(Simple(datetime.date.today))(datetime.date(2018, 9, 17))
ValidationError: [u'Ensure this value is greater than or equal to
2018-09-19.']
}}}

I get my expected result.

This doesn't seem like an unreasonable ask.

--
Ticket URL: <https://code.djangoproject.com/ticket/29772>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 19, 2018, 10:42:21 AM9/19/18
to django-...@googlegroups.com
#29772: SimpleLazyObject doesn't implement __gt__ / __lt__
------------------------------+------------------------------------

Reporter: Javier Buzzi | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Simon Charette):

* type: Uncategorized => New feature
* component: Uncategorized => Core (Other)
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:1>

Django

unread,
Sep 19, 2018, 11:29:51 AM9/19/18
to django-...@googlegroups.com
#29772: SimpleLazyObject doesn't implement __gt__ / __lt__
------------------------------+------------------------------------

Reporter: Javier Buzzi | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Javier Buzzi):

@Simon Charette Can this go into 2.0 or.. 1.x? If not i'll wait i suppose.
This diff can be back ported without difficulty. Ps. i have PR:
https://github.com/django/django/pull/10419 not sure where to put it.

--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:2>

Django

unread,
Sep 19, 2018, 12:47:14 PM9/19/18
to django-...@googlegroups.com
#29772: SimpleLazyObject doesn't implement __gt__ / __lt__
-------------------------------------+-------------------------------------

Reporter: Javier Buzzi | Owner: nobody
Type: New feature | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* version: 2.1 => master
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:3>

Django

unread,
Sep 19, 2018, 1:51:38 PM9/19/18
to django-...@googlegroups.com
#29772: SimpleLazyObject doesn't implement __gt__ / __lt__
-------------------------------------+-------------------------------------

Reporter: Javier Buzzi | Owner: nobody
Type: New feature | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"a0d63b02c34e6d18d7219cce4d828f71432265e9" a0d63b0]:
{{{
#!CommitTicketReference repository=""
revision="a0d63b02c34e6d18d7219cce4d828f71432265e9"
Fixed #29772 -- Made LazyObject proxy __lt__() and __gt__().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29772#comment:4>

Reply all
Reply to author
Forward
0 new messages