From ee51aa4bf8da3b26c651f08e9055aedc047c422e Mon Sep 17 00:00:00 2001 From: snmishra Date: Sun, 25 Jul 2021 05:06:22 -0500 Subject: [PATCH] Add datetime to DateTimeField (#675) * Add datetime to set_type of DateTimeField `DateTimeField` was missing `datetime` as a valid set type. But Django clearly accepts `datetime`. * Fix test for DateTimeField type change datetime is now a valid set type for DateTimeField --- django-stubs/db/models/fields/__init__.pyi | 1 + tests/typecheck/models/test_init.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 38c7175..388af37 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -451,6 +451,7 @@ class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): ): ... class DateTimeField(DateField[_ST, _GT]): + _pyi_private_set_type: Union[str, datetime, date, Combinable] _pyi_private_get_type: datetime _pyi_lookup_exact_type: Union[str, datetime] diff --git a/tests/typecheck/models/test_init.yml b/tests/typecheck/models/test_init.yml index 8af7c4f..c0e62d8 100644 --- a/tests/typecheck/models/test_init.yml +++ b/tests/typecheck/models/test_init.yml @@ -127,7 +127,7 @@ from myapp.models import Publisher, PublisherDatetime, Book Book(publisher_id=1, publisher_dt_id=now) Book(publisher_id=[], publisher_dt_id=now) # E: Incompatible type for "publisher_id" of "Book" (got "List[Any]", expected "Union[Combinable, int, str, None]") - Book(publisher_id=1, publisher_dt_id=1) # E: Incompatible type for "publisher_dt_id" of "Book" (got "int", expected "Union[str, date, Combinable, None]") + Book(publisher_id=1, publisher_dt_id=1) # E: Incompatible type for "publisher_dt_id" of "Book" (got "int", expected "Union[str, datetime, date, Combinable, None]") installed_apps: - myapp files: