mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-05-11 09:08:28 +08:00
Improve type of BaseForms.files (#350)
This is valid Django, which failed to pass with the old type-defintion:
class MyForm(Form):
myparam = MultiFileField(...)
self.clean(self, *args, **kwargs):
self.files.getlist('myparam', [])
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union
|
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError as ValidationError
|
from django.core.exceptions import ValidationError as ValidationError
|
||||||
|
from django.core.files import uploadedfile
|
||||||
from django.forms.boundfield import BoundField
|
from django.forms.boundfield import BoundField
|
||||||
from django.forms.fields import Field
|
from django.forms.fields import Field
|
||||||
from django.forms.renderers import BaseRenderer
|
from django.forms.renderers import BaseRenderer
|
||||||
from django.forms.utils import ErrorDict, ErrorList
|
from django.forms.utils import ErrorDict, ErrorList
|
||||||
from django.forms.widgets import Media, MediaDefiningClass
|
from django.forms.widgets import Media, MediaDefiningClass
|
||||||
|
from django.utils.datastructures import MultiValueDict
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
|
|
||||||
class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
|
class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
|
||||||
@@ -18,7 +20,7 @@ class BaseForm:
|
|||||||
use_required_attribute: bool = ...
|
use_required_attribute: bool = ...
|
||||||
is_bound: bool = ...
|
is_bound: bool = ...
|
||||||
data: Dict[str, Any] = ...
|
data: Dict[str, Any] = ...
|
||||||
files: Optional[Dict[str, Any]] = ...
|
files: MultiValueDict[str, uploadedfile.UploadedFile] = ...
|
||||||
auto_id: str = ...
|
auto_id: str = ...
|
||||||
initial: Dict[str, Any] = ...
|
initial: Dict[str, Any] = ...
|
||||||
error_class: Type[ErrorList] = ...
|
error_class: Type[ErrorList] = ...
|
||||||
|
|||||||
Reference in New Issue
Block a user