#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
               Reporter:  Sobolev    |          Owner:  Sobolev Nikita
  Nikita                             |
                   Type:             |         Status:  assigned
  Uncategorized                      |
              Component:             |        Version:  5.0
  contrib.contenttypes               |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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>
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/0107018f3d96aaa7-8a8af907-f81c-4643-bcb5-25d5aedd1f58-000000%40eu-central-1.amazonses.com.

Reply via email to