Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.0: Update django.contrib.admin.widgets #2105

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions django-stubs/contrib/admin/widgets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@ class FilteredSelectMultiple(forms.SelectMultiple):
choices: _Choices = ...,
) -> None: ...

class AdminDateWidget(forms.DateInput):
class BaseAdminDateWidget(forms.DateInput):
class Media:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @flaeppe

I think that defining such classes may cause an error when defining subclasses of widgets.

It is close to out Meta case.

Copy link
Contributor Author

@JaeHyuckSa JaeHyuckSa May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sobolvn I get an error in stustest if I delete that Media case. What should I do about this??

error: django.contrib.admin.widgets.BaseAdminDateWidget.Media is not present in stub
Stub: in file /Users/sajh/Documents/project/django-stubs/django-stubs/contrib/admin/widgets.pyi
MISSING
Runtime: in file /Users/sajh/.pyenv/versions/3.11.5/lib/python3.11/site-packages/django/contrib/admin/widgets.py:53
def ()

error: django.contrib.admin.widgets.BaseAdminTimeWidget.Media is not present in stub
Stub: in file /Users/sajh/Documents/project/django-stubs/django-stubs/contrib/admin/widgets.pyi
MISSING
Runtime: in file /Users/sajh/.pyenv/versions/3.11.5/lib/python3.11/site-packages/django/contrib/admin/widgets.py:69
def ()

Should I not delete that part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ignore it for now, we can later decide what to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I revised what you said :)

js: Sequence[str]

def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ...

class AdminTimeWidget(forms.TimeInput):
class AdminDateWidget(BaseAdminDateWidget):
template_name: str

class BaseAdminTimeWidget(forms.TimeInput):
class Media:
js: Sequence[str]

def __init__(self, attrs: _OptAttrs | None = ..., format: str | None = ...) -> None: ...

class AdminTimeWidget(BaseAdminTimeWidget):
template_name: str

class AdminSplitDateTime(forms.SplitDateTimeWidget):
template_name: str
def __init__(self, attrs: _OptAttrs | None = ...) -> None: ...
Expand Down Expand Up @@ -70,7 +82,6 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):

class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str
choices: ModelChoiceIterator
widget: forms.ChoiceWidget
rel: ManyToOneRel
can_add_related: bool
Expand All @@ -90,6 +101,10 @@ class RelatedFieldWidgetWrapper(forms.Widget):
) -> None: ...
@property
def is_hidden(self) -> bool: ...
@property
def choices(self) -> ModelChoiceIterator: ...
@choices.setter
def choices(self, value: ModelChoiceIterator) -> None: ...
def get_related_url(self, info: tuple[str, str], action: str, *args: Any) -> str: ...
def get_context(self, name: str, value: Any, attrs: _OptAttrs | None) -> dict[str, Any]: ...
def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ...
Expand Down
2 changes: 0 additions & 2 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ django.contrib.admin.views.autocomplete.AutocompleteJsonView.process_request
django.contrib.admin.views.autocomplete.AutocompleteJsonView.serialize_result
django.contrib.admin.views.main.ChangeList.search_form_class
django.contrib.admin.widgets.AutocompleteMixin.media
django.contrib.admin.widgets.BaseAdminDateWidget
django.contrib.admin.widgets.BaseAdminTimeWidget
django.contrib.admin.widgets.FilteredSelectMultiple.Media
django.contrib.admin.widgets.get_select2_language
django.contrib.admindocs.utils.non_capturing_group_matcher
Expand Down
Loading