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
This commit is contained in:
snmishra
2021-07-25 05:06:22 -05:00
committed by GitHub
parent ee9c0d4a32
commit ee51aa4bf8
2 changed files with 2 additions and 1 deletions

View File

@@ -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]

View File

@@ -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: