django-stubs
django-stubs copied to clipboard
request.FILES items are resolved as UploadedFile | list[object] instead of UploadedFile
Bug report
It seems that multidict items are not resolved correctly.
if request.FILES:
for key, uploaded in request.FILES.items():
reveal_type(uploaded)
What's wrong
Type is resolved as:
UploadedFile | list[object]
instead of just UploadedFile.
def items(self):
"""
Yield (key, value) pairs, where value is the last item in the list
associated with the key.
"""
for key in self:
yield key, self[key]
So if there are multi values under one key ... only last item in the list is returned.
How is that should be
Type should be just UploadedFile.
System information
- OS:
-
python
version: 3.11.2 -
django
version: 4.2.5 -
mypy
version: 1.5.1 -
django-stubs
version: 4.2.3 -
django-stubs-ext
version: 4.2.2
PR is welcome