You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #909, the BaseForm class's files attribute (and everything related to it, like the files argument to Widget.value_from_datadict) were updated to _FilesT, which is defined as Mapping[str, Iterable[File]]. Unless there are counterexamples in the Django codebase that I haven't seen, I'm pretty sure this can be more specific than Mapping - it appears to be a MultiValueDict (which is what this was typed as in previous versions of django-stubs).
Is it safe to assume that this is a MultiValueDict everywhere, or can users only rely on it being a Mapping?
The text was updated successfully, but these errors were encountered:
Using Iterable was definitely a mistake, yes, it should have been Mapping[str, File].
I will revert this for now in #925 and use MultiValueDict[str, UploadedFile] for now again. I see the point that Mapping[str, Iterable[File]] is absolutely invalid (it doesn't return iterables as values) and Mapping[str, UploadedFile] doesn't work with multiple files upload (no .getlist method). However, there's problem with MultiValueDict[str, UploadedFile] too: it invalidates all test cases where we use MyForm({}, {'file_field': UploadedFile(...)}).
I think this case needs discussion and mainainer's final decision.
@sobolevn I'm sure you're one of maintainers, please resolve this or ping somebody else :)
Bug report
In #909, the
BaseForm
class'sfiles
attribute (and everything related to it, like thefiles
argument toWidget.value_from_datadict
) were updated to_FilesT
, which is defined asMapping[str, Iterable[File]]
. Unless there are counterexamples in the Django codebase that I haven't seen, I'm pretty sure this can be more specific thanMapping
- it appears to be aMultiValueDict
(which is what this was typed as in previous versions of django-stubs).Is it safe to assume that this is a
MultiValueDict
everywhere, or can users only rely on it being aMapping
?The text was updated successfully, but these errors were encountered: