Disable assuming Optional type for values with None default (#16029)

https://www.python.org/dev/peps/pep-0484/#union-types
"Type checkers should move towards requiring the optional type to be
made explicit."
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2018-08-17 20:22:49 +02:00
1 parent 2ad0bd4036
commit 3800f00564
9 files changed
+24 -17

No files matched your search

+3 -3
View File
@@ -53,7 +53,7 @@ def utcnow() -> dt.datetime:
return dt.datetime.now(UTC)
def now(time_zone: dt.tzinfo = None) -> dt.datetime:
def now(time_zone: Optional[dt.tzinfo] = None) -> dt.datetime:
"""Get now in specified time zone."""
return dt.datetime.now(time_zone or DEFAULT_TIME_ZONE)
@@ -97,8 +97,8 @@ def utc_from_timestamp(timestamp: float) -> dt.datetime:
return UTC.localize(dt.datetime.utcfromtimestamp(timestamp))
def start_of_local_day(dt_or_d:
Union[dt.date, dt.datetime] = None) -> dt.datetime:
def start_of_local_day(
dt_or_d: Union[dt.date, dt.datetime, None] = None) -> dt.datetime:
"""Return local datetime object of start of day from date or datetime."""
if dt_or_d is None:
date = now().date() # type: dt.date