#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
     Reporter:  Sobolev Nikita       |                    Owner:  Sobolev
                                     |  Nikita
         Type:  Uncategorized        |                   Status:  assigned
    Component:                       |                  Version:  5.0
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Sobolev Nikita:

Old description:

> Original issue: https://code.djangoproject.com/ticket/33651
>
> Source:
> https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7
>
> Right now this code is really strange. It produces this result:
>
> ```
> >>> import django
> >>> from django.contrib.contenttypes.prefetch import GenericPrefetch
> >>> GenericPrefetch('a')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/Users/sobolev/Documents/github/wemake-django-
> template/.venv/lib/python3.11/site-
> packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__
>     for queryset in querysets:
> TypeError: 'NoneType' object is not iterable
> ```
>
> I guess that there are two ways:
> - Using `if querysets is None: querysets = []`
> - Requiring this argument, which I guess is the correct thing to do. Why
> would we ever want this field to be empty?
>
> I will send a PR with the fix.
>
> I found this while working on https://github.com/typeddjango/django-
> stubs/pull/2115

New description:

 Original issue: https://code.djangoproject.com/ticket/33651

 Source:
 
https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7

 Right now this code is really strange. It produces this result:


 {{{
 >>> import django
 >>> from django.contrib.contenttypes.prefetch import GenericPrefetch
 >>> GenericPrefetch('a')
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/Users/sobolev/Documents/github/wemake-django-
 template/.venv/lib/python3.11/site-
 packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__
     for queryset in querysets:
 TypeError: 'NoneType' object is not iterable
 }}}


 I guess that there are two ways:
 - Using `if querysets is None: querysets = []`
 - Requiring this argument, which I guess is the correct thing to do. Why
 would we ever want this field to be empty?

 I will send a PR with the fix.

 I found this while working on https://github.com/typeddjango/django-
 stubs/pull/2115

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35426#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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f3d975a5f-07d9e5e9-bf78-4e32-babb-847f97742ca5-000000%40eu-central-1.amazonses.com.

Reply via email to