#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 19 months ago by nickbruun

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 19 months ago by timo

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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

comment:3 Changed 19 months ago by nickbruun

  • Patch needs improvement unset

comment:4 Changed 19 months ago by nickbruun

  • Patch needs improvement set

comment:5 Changed 19 months ago by nickbruun

  • Patch needs improvement unset

Patch updated.

comment:6 Changed 19 months ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top