From e4929f4b599f2a5dce2a4eef2e680a3cc5fac08a Mon Sep 17 00:00:00 2001 From: Roy Williams Date: Tue, 29 Nov 2016 15:54:11 -0800 Subject: [PATCH 1/2] Expose pytz.UTC as an instance as opposed to as a class pytz shadows UTC after declaring it with a singleton: https://github.com/newvem/pytz/blob/master/pytz/__init__.py#L135 This fixes https://github.com/python/typeshed/issues/710 --- third_party/2and3/pytz/__init__.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/pytz/__init__.pyi b/third_party/2and3/pytz/__init__.pyi index dc9c8fc4a332..2b219f98fc76 100644 --- a/third_party/2and3/pytz/__init__.pyi +++ b/third_party/2and3/pytz/__init__.pyi @@ -11,7 +11,7 @@ country_timezones = ... # type: Dict country_names = ... # type: Dict -class UTC(dt.tzinfo): +class __UTC(dt.tzinfo): zone = ... # type: str def fromutc(self, dt: dt.datetime) -> dt.datetime: ... def utcoffset(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore @@ -20,6 +20,7 @@ class UTC(dt.tzinfo): def localize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... def normalize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... -utc = ... # type: UTC +utc = ... # type: __UTC +UTC = ... # type: __UTC -def timezone(zone: str) -> UTC: ... +def timezone(zone: str) -> dt.tzinfo: ... From 0d98165c0eaf55549c5f6111f47c52484e7408bf Mon Sep 17 00:00:00 2001 From: Roy Williams Date: Tue, 29 Nov 2016 21:42:36 -0800 Subject: [PATCH 2/2] s/__UTC/_UTCclass --- third_party/2and3/pytz/__init__.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/pytz/__init__.pyi b/third_party/2and3/pytz/__init__.pyi index 2b219f98fc76..6bc917e5e573 100644 --- a/third_party/2and3/pytz/__init__.pyi +++ b/third_party/2and3/pytz/__init__.pyi @@ -11,7 +11,7 @@ country_timezones = ... # type: Dict country_names = ... # type: Dict -class __UTC(dt.tzinfo): +class _UTCclass(dt.tzinfo): zone = ... # type: str def fromutc(self, dt: dt.datetime) -> dt.datetime: ... def utcoffset(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore @@ -20,7 +20,7 @@ class __UTC(dt.tzinfo): def localize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... def normalize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... -utc = ... # type: __UTC -UTC = ... # type: __UTC +utc = ... # type: _UTCclass +UTC = ... # type: _UTCclass def timezone(zone: str) -> dt.tzinfo: ...