Opened 3 years ago

Closed 3 years ago

#20924 closed Bug (fixed)

LazyObject missing __contains__ and __len__ proxy

Reported by: nickbruun Owned by: nobody
Component: Utilities Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

django.utils.functionals.LazyObject does not proxy the __contains__ and __len__ data methods. This means that the following use cases for lazy objects that return lists, sets or dicts are not possible:

key in lazy_object
len(lazy_object)

Fixing this is trivial as has been shown by the current proxying implementation of __getitem__, __setitem__ and __delitem__. Regression test and patch is available on Github at https://github.com/nickbruun/django.

Change History (6)

comment:1 in reply to:  description Changed 3 years ago by nickbruun

comment:2 Changed 3 years ago by Tim Graham

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Please untick "Patch needs improvement" when you can update the PR per the comment, thanks!

comment:3 Changed 3 years ago by nickbruun

Patch needs improvement: unset

comment:4 Changed 3 years ago by nickbruun

Patch needs improvement: set

comment:5 Changed 3 years ago by nickbruun

Patch needs improvement: unset

Patch updated.

comment:6 Changed 3 years ago by anonymous

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top