From ca36070d51890f8a153d59ab6ea67a14e609df56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Marsza=C5=82ek?= Date: Fri, 3 Feb 2017 19:54:59 +0100 Subject: [PATCH] Improved pytz support for timezone function (#911) --- third_party/2/requests/api.pyi | 14 ++++++------ third_party/2and3/pytz/__init__.pyi | 33 ++++++++++++++++++++--------- third_party/3/requests/api.pyi | 14 ++++++------ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/third_party/2/requests/api.pyi b/third_party/2/requests/api.pyi index 9f041d21c..fee191eae 100644 --- a/third_party/2/requests/api.pyi +++ b/third_party/2/requests/api.pyi @@ -4,18 +4,18 @@ from typing import Union, Optional, Iterable, Mapping, Tuple from .models import Response -ParamsMappingValueType = Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]] +_ParamsMappingValueType = Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]] def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, unicode], params: Optional[ - Union[Mapping[Union[str, unicode, int, float], ParamsMappingValueType], + Union[Mapping[Union[str, unicode, int, float], _ParamsMappingValueType], Union[str, unicode], - Tuple[Union[str, unicode, int, float], ParamsMappingValueType], - Mapping[str, ParamsMappingValueType], - Mapping[unicode, ParamsMappingValueType], - Mapping[int, ParamsMappingValueType], - Mapping[float, ParamsMappingValueType]]] = None, + Tuple[Union[str, unicode, int, float], _ParamsMappingValueType], + Mapping[str, _ParamsMappingValueType], + Mapping[unicode, _ParamsMappingValueType], + Mapping[int, _ParamsMappingValueType], + Mapping[float, _ParamsMappingValueType]]] = None, **kwargs) -> Response: ... def options(url: Union[str, unicode], **kwargs) -> Response: ... def head(url: Union[str, unicode], **kwargs) -> Response: ... diff --git a/third_party/2and3/pytz/__init__.pyi b/third_party/2and3/pytz/__init__.pyi index 6bc917e5e..2c2accd67 100644 --- a/third_party/2and3/pytz/__init__.pyi +++ b/third_party/2and3/pytz/__init__.pyi @@ -1,7 +1,7 @@ # Stubs for pytz (Python 3.5) -import datetime as dt -from typing import Optional, List, Set, Dict # NOQA +import datetime +from typing import Optional, List, Set, Dict, Union all_timezones = ... # type: List all_timezones_set = ... # type: Set @@ -11,16 +11,29 @@ country_timezones = ... # type: Dict country_names = ... # type: Dict -class _UTCclass(dt.tzinfo): +class _UTCclass(datetime.tzinfo): zone = ... # type: str - def fromutc(self, dt: dt.datetime) -> dt.datetime: ... - def utcoffset(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore - def tzname(self, dt: Optional[dt.datetime]) -> str: ... - def dst(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore - def localize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... - def normalize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... + def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ... + def utcoffset(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def tzname(self, dt: Optional[datetime.datetime]) -> str: ... + def dst(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def localize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... + def normalize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... utc = ... # type: _UTCclass UTC = ... # type: _UTCclass -def timezone(zone: str) -> dt.tzinfo: ... + +class _BaseTzInfo(datetime.tzinfo): + zone = ... # type: str + + def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ... + def localize(self, dt: datetime.datetime, is_dst: Optional[bool] = ...) -> datetime.datetime: ... + def normalize(self, dt: datetime.datetime) -> datetime.datetime: ... + + +class _StaticTzInfo(_BaseTzInfo): + def normalize(self, dt: datetime.datetime, is_dst: Optional[bool] = ...) -> datetime.datetime: ... + + +def timezone(zone: str) -> _BaseTzInfo: ... diff --git a/third_party/3/requests/api.pyi b/third_party/3/requests/api.pyi index 120f695c4..432a82002 100644 --- a/third_party/3/requests/api.pyi +++ b/third_party/3/requests/api.pyi @@ -4,19 +4,19 @@ from typing import Optional, Union, Any, Iterable, Mapping, Tuple from .models import Response -ParamsMappingValueType = Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]] +_ParamsMappingValueType = Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]] def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, bytes], params: Optional[ Union[ - Mapping[Union[str, bytes, int, float], ParamsMappingValueType], + Mapping[Union[str, bytes, int, float], _ParamsMappingValueType], Union[str, bytes], - Tuple[Union[str, bytes, int, float], ParamsMappingValueType], - Mapping[str, ParamsMappingValueType], - Mapping[bytes, ParamsMappingValueType], - Mapping[int, ParamsMappingValueType], - Mapping[float, ParamsMappingValueType]]]=None, + Tuple[Union[str, bytes, int, float], _ParamsMappingValueType], + Mapping[str, _ParamsMappingValueType], + Mapping[bytes, _ParamsMappingValueType], + Mapping[int, _ParamsMappingValueType], + Mapping[float, _ParamsMappingValueType]]]=None, **kwargs) -> Response: ... def options(url: str, **kwargs) -> Response: ... def head(url: str, **kwargs) -> Response: ...