-
-
Notifications
You must be signed in to change notification settings - Fork 526
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Typing for prefetch_related_objects says that it can accept Iterable, but code indicates that it should be a Sequence (I suppose)
Rel. to this typing stubs
django-stubs/django-stubs/db/models/query.pyi
Line 288 in 51beeee
| def prefetch_related_objects(model_instances: Iterable[_Model], *related_lookups: str | Prefetch) -> None: ... |
Django 5.2.8
What's wrong
Typing for prefetch_related_objects says that it can accept Iterable, but if we will call it with set, frozenset, keys or values view, we will see this error
2370 break
2372 # Descend down tree
2373
2374 # We assume that objects retrieved are homogeneous (which is the premise
2375 # of prefetch_related), so what applies to first object applies to all.
-> 2376 first_obj = obj_list[0]
2377 to_attr = lookup.get_current_to_attr(level)[0]
2378 prefetcher, descriptor, attr_found, is_fetched = get_prefetcher(
2379 first_obj, through_attr, to_attr
2380 )
TypeError: 'set' object is not subscriptable
UnknownPlatypus
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working