diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 5b2146c..bfa2351 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -61,10 +61,10 @@ class BaseModelAdmin: def formfield_for_choice_field(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> TypedChoiceField: ... def get_field_queryset(self, db: None, db_field: RelatedField, request: WSGIRequest) -> Optional[QuerySet]: ... def formfield_for_foreignkey( - self, db_field: ForeignKey, request: WSGIRequest, **kwargs: Any + self, db_field: ForeignKey, request: Optional[WSGIRequest], **kwargs: Any ) -> Optional[ModelChoiceField]: ... def formfield_for_manytomany( - self, db_field: ManyToManyField, request: WSGIRequest, **kwargs: Any + self, db_field: ManyToManyField, request: Optional[WSGIRequest], **kwargs: Any ) -> ModelMultipleChoiceField: ... def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ... def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ... diff --git a/django-stubs/contrib/admin/utils.pyi b/django-stubs/contrib/admin/utils.pyi index 7fd9db9..cc54957 100644 --- a/django-stubs/contrib/admin/utils.pyi +++ b/django-stubs/contrib/admin/utils.pyi @@ -43,7 +43,7 @@ class NestedObjects(Collector): def add_edge(self, source: Optional[Model], target: Model) -> None: ... def collect( self, - objs: Union[Sequence[Model], QuerySet], + objs: Union[Sequence[Optional[Model]], QuerySet], source: Optional[Type[Model]] = ..., source_attr: Optional[str] = ..., **kwargs: Any diff --git a/django-stubs/contrib/auth/admin.pyi b/django-stubs/contrib/auth/admin.pyi index 2d77835..2c541eb 100644 --- a/django-stubs/contrib/auth/admin.pyi +++ b/django-stubs/contrib/auth/admin.pyi @@ -1,9 +1,13 @@ -from typing import Any, Dict, List, Optional, Tuple, Type +from typing import Any, Dict, List, Optional, Tuple, Type, Union from django.contrib.auth.models import User, Group from django.core.handlers.wsgi import WSGIRequest +from django.db.models.fields import Field from django.db.models.fields.related import ManyToManyField +from django.db.models.options import Options from django.forms.models import ModelMultipleChoiceField +from django.forms.fields import Field as FormField +from django.forms.widgets import Widget from django.http.response import HttpResponse from django.urls.resolvers import URLPattern @@ -27,10 +31,7 @@ class GroupAdmin(admin.ModelAdmin): class UserAdmin(admin.ModelAdmin): admin_site: AdminSite - formfield_overrides: Dict[ - Type[Union[django.db.models.fields.DateTimeCheckMixin, Field]], - Dict[str, Type[Union[django.forms.fields.SplitDateTimeField, Widget]]], - ] + formfield_overrides: Dict[Type[Field], Dict[str, Type[Union[FormField, Widget]]]] model: Type[User] opts: Options add_form_template: str = ... diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index 2676046..7c1a3d5 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -46,12 +46,12 @@ class FieldRelatedOptionOperation(ModelOptionOperation): ... class AlterUniqueTogether(FieldRelatedOptionOperation): option_name: str = ... unique_together: Collection[Sequence[str]] = ... - def __init__(self, name: str, unique_together: Collection[Sequence[str]]) -> None: ... + def __init__(self, name: str, unique_together: Optional[Collection[Sequence[str]]]) -> None: ... class AlterIndexTogether(FieldRelatedOptionOperation): option_name: str = ... index_together: Collection[Sequence[str]] = ... - def __init__(self, name: str, index_together: Collection[Sequence[str]]) -> None: ... + def __init__(self, name: str, index_together: Optional[Collection[Sequence[str]]]) -> None: ... class AlterOrderWithRespectTo(FieldRelatedOptionOperation): order_with_respect_to: str = ... diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 04b6e6f..e50943e 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -33,7 +33,7 @@ class HttpResponseBase(Iterable[AnyStr]): def has_header(self, header: str) -> bool: ... def items(self) -> Iterable[Tuple[str, str]]: ... @overload - def get(self, header: Union[str, bytes], alternate: str) -> str: ... + def get(self, header: Union[str, bytes], alternate: Optional[str]) -> str: ... @overload def get(self, header: Union[str, bytes]) -> Optional[str]: ... def set_cookie(