Skip to content

Commit 144ad00

Browse files
committed
Add more attribute to fields
1 parent 85547a8 commit 144ad00

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

rest_framework-stubs/fields.pyi

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,21 @@ class Field:
5454
default_validators: List[Callable] = ...
5555
default_empty_html: Any = ...
5656
initial: Optional[Any] = ...
57+
read_only: bool = ...
58+
write_only: bool = ...
59+
required: bool = ...
60+
default: Any = ...
61+
initial: Any = ...
62+
source: Optional[Union[Callable, str]] = ...
63+
label: Optional[str] = ...
64+
help_text: Optional[str] = ...
65+
style: Mapping[str, Any] = ...
66+
error_messages: Mapping[str, str] = ...
67+
validators: List[_Validator] = ...
68+
allow_null: bool = ...
69+
field_name: Optional[str] = ...
5770
# TODO: add Generic/Plugin support for parent
58-
parent: Optional[Any]
59-
validators: Optional[List[_Validator]]
71+
parent: Optional[Any] = ...
6072
def __init__(
6173
self,
6274
read_only: bool = ...,
@@ -67,10 +79,10 @@ class Field:
6779
source: Union[Callable, str] = ...,
6880
label: Optional[str] = ...,
6981
help_text: str = ...,
70-
allow_null: bool = ...,
71-
validators: Optional[Sequence[_Validator]] = ...,
72-
error_messages: Optional[Mapping[str, str]] = ...,
7382
style: Optional[Mapping[str, Any]] = ...,
83+
error_messages: Optional[Mapping[str, str]] = ...,
84+
validators: Optional[Sequence[_Validator]] = ...,
85+
allow_null: bool = ...,
7486
): ...
7587
def bind(self, field_name: str, parent: BaseSerializer) -> None: ...
7688
def get_validators(self) -> List[Callable]: ...
@@ -102,6 +114,10 @@ class NullBooleanField(Field):
102114
class CharField(Field):
103115
_pyi_field_actual_type: str
104116
_pyi_field_primitive_type: str
117+
allow_blank: bool = ...
118+
trim_whitespace: bool = ...
119+
min_length: Optional[int] = ...
120+
max_length: Optional[int] = ...
105121
def __init__(
106122
self,
107123
read_only: bool = ...,
@@ -387,6 +403,7 @@ class ChoiceField(Field):
387403
choices: Sequence[Any]
388404
html_cutoff: Optional[int] = ...
389405
html_cutoff_text: Optional[str] = ...
406+
allow_blank: bool = ...
390407
def __init__(
391408
self,
392409
choices: Sequence[Any],
@@ -411,6 +428,7 @@ class ChoiceField(Field):
411428
def _set_choices(self, choices: Sequence[Any]) -> None: ...
412429

413430
class MultipleChoiceField(ChoiceField):
431+
allow_empty: bool = ...
414432
def __init__(
415433
self,
416434
choices: Sequence[Any],
@@ -482,6 +500,7 @@ class SupportsToPython(Protocol):
482500

483501
class ImageField(FileField):
484502
_DjangoImageField: SupportsToPython
503+
allow_empty: bool = ...
485504
def __init__(
486505
self,
487506
_DjangoImageField: Type[SupportsToPython] = ...,

rest_framework-stubs/relations.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class ManyRelatedField(Field):
9191
default_empty_html: List[object] = ...
9292
html_cutoff: Optional[int] = ...
9393
html_cutoff_text: Optional[str] = ...
94+
child_relation: RelatedField = ...
95+
allow_empty: bool = ...
9496
def __init__(self, child_relation: Optional[RelatedField] = ..., *args: Any, **kwargs: Any) -> None: ...
9597
def get_choices(self, cutoff: Optional[int] = ...) -> _Choices: ...
9698
@property

0 commit comments

Comments
 (0)