#35915: QueryDict __getitem__ returns an empty list when the value is an empty 
list
--------------------------------------+------------------------------------
     Reporter:  Nguyễn Hồng Quân      |                    Owner:  (none)
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  HTTP handling         |                  Version:  5.1
     Severity:  Normal                |               Resolution:
     Keywords:  querydict             |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

 * stage:  Unreviewed => Accepted
 * summary:  QueryDict __getitem__ returns list which is surpising =>
     QueryDict __getitem__ returns an empty list when the value is an empty
     list

Comment:

 > Could we change this behavior? I know that we don't have a perfect
 solution, but returning None in this case is less bad than empty list [],
 because it is easier to annotate type.

 It's been this way a very long time, I'm not sure what the implications of
 changing it would be (in terms of compatibility). I also think changing it
 for easier type annotations is not a strong argument here. You could raise
 this topic on the [https://forum.djangoproject.com/ Django forum] and get
 others opinions if you wish to change it.

 That being said, I think a docs adjustment is required (note that the
 docstring states `Return the last data value for this key, or [] if it's
 an empty list; raise KeyError if not found.`).
 Accepting on that basis.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35915#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701933eb3487f-72adb8e1-460e-4032-9aa1-df4b00431b17-000000%40eu-central-1.amazonses.com.

Reply via email to