Skip to content

Commit

Permalink
Broaden type annotation for label to accept lazystr.
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
  • Loading branch information
PIG208 committed Aug 29, 2022
1 parent 323f6db commit 6ccb678
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions django-stubs/contrib/admin/sites.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.template.response import TemplateResponse
from django.urls import URLPattern, URLResolver
from django.utils.functional import LazyObject
from django.utils.functional import LazyObject, _StrOrPromise

if sys.version_info >= (3, 9):
from weakref import WeakSet
Expand Down Expand Up @@ -77,7 +77,7 @@ class AdminSite:
def i18n_javascript(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def logout(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def login(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def _build_app_dict(self, request: HttpRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
def _build_app_dict(self, request: HttpRequest, label: Optional[_StrOrPromise] = ...) -> Dict[str, Any]: ...
def get_app_list(self, request: HttpRequest) -> List[Any]: ...
def index(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def app_index(
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/forms/boundfield.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BoundField:
html_name: str = ...
html_initial_name: str = ...
html_initial_id: str = ...
label: str = ...
label: _StrOrPromise = ...
help_text: _StrOrPromise = ...
def __init__(self, form: BaseForm, field: Field, name: str) -> None: ...
@property
Expand Down
40 changes: 20 additions & 20 deletions django-stubs/forms/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _ClassLevelWidgetT = Any

class Field:
initial: Any
label: Optional[str]
label: Optional[_StrOrPromise]
required: bool
widget: _ClassLevelWidgetT = ...
hidden_widget: Type[Widget] = ...
Expand All @@ -43,7 +43,7 @@ class Field:
*,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -78,7 +78,7 @@ class CharField(Field):
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -102,7 +102,7 @@ class IntegerField(Field):
min_value: Optional[int] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -123,7 +123,7 @@ class FloatField(IntegerField):
min_value: Union[int, float, None] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -149,7 +149,7 @@ class DecimalField(IntegerField):
decimal_places: Optional[int] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -171,7 +171,7 @@ class BaseTemporalField(Field):
input_formats: Optional[Any] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -215,7 +215,7 @@ class RegexField(CharField):
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -236,7 +236,7 @@ class EmailField(CharField):
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -256,7 +256,7 @@ class FileField(Field):
allow_empty_file: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -285,7 +285,7 @@ class URLField(CharField):
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -323,7 +323,7 @@ class ChoiceField(Field):
choices: Union[_FieldChoices, _ChoicesCallable] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -353,7 +353,7 @@ class TypedChoiceField(ChoiceField):
choices: Union[_FieldChoices, _ChoicesCallable] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -381,7 +381,7 @@ class TypedMultipleChoiceField(MultipleChoiceField):
choices: Union[_FieldChoices, _ChoicesCallable] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -402,7 +402,7 @@ class ComboField(Field):
*,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -424,7 +424,7 @@ class MultiValueField(Field):
require_all_fields: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down Expand Up @@ -457,7 +457,7 @@ class FilePathField(ChoiceField):
choices: Union[_FieldChoices, _ChoicesCallable] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -478,7 +478,7 @@ class SplitDateTimeField(MultiValueField):
require_all_fields: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -499,7 +499,7 @@ class GenericIPAddressField(CharField):
unpack_ipv4: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand All @@ -523,7 +523,7 @@ class SlugField(CharField):
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
Expand Down
8 changes: 4 additions & 4 deletions django-stubs/forms/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,18 @@ class ModelChoiceField(ChoiceField):
validators: List[Any]
default_error_messages: Dict[str, str] = ...
iterator: Type[ModelChoiceIterator] = ...
empty_label: Optional[str] = ...
empty_label: Optional[_StrOrPromise] = ...
queryset: Optional[QuerySet[models.Model]] = ...
limit_choices_to: Optional[_AllLimitChoicesTo] = ...
to_field_name: Optional[str] = ...
def __init__(
self,
queryset: Union[None, Manager[models.Model], QuerySet[models.Model]],
*,
empty_label: Optional[str] = ...,
empty_label: Optional[_StrOrPromise] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[str] = ...,
label: Optional[_StrOrPromise] = ...,
initial: Optional[Any] = ...,
help_text: _StrOrPromise = ...,
to_field_name: Optional[str] = ...,
Expand All @@ -307,7 +307,7 @@ class ModelChoiceField(ChoiceField):

class ModelMultipleChoiceField(ModelChoiceField):
disabled: bool
empty_label: Optional[str]
empty_label: Optional[_StrOrPromise]
help_text: _StrOrPromise
required: bool
show_hidden_initial: bool
Expand Down

0 comments on commit 6ccb678

Please sign in to comment.