From 6d1edb285d487011de695915e64c01b28a4034bf Mon Sep 17 00:00:00 2001 From: Lucas Wiman Date: Fri, 27 Jan 2017 08:03:25 -0800 Subject: [PATCH] Expand several stdlib methods to accept unicode or str. (#869) Expand several stdlib methods to accept unicode or str. --- stdlib/2/collections.pyi | 2 +- stdlib/2/datetime.pyi | 8 ++++---- stdlib/2/decimal.pyi | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/2/collections.pyi b/stdlib/2/collections.pyi index 74fc2a801..18bfdfcd4 100644 --- a/stdlib/2/collections.pyi +++ b/stdlib/2/collections.pyi @@ -18,7 +18,7 @@ _KT = TypeVar('_KT') _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *, +def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Any]], *, verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ... class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): diff --git a/stdlib/2/datetime.pyi b/stdlib/2/datetime.pyi index e7f4b44fd..6174b9a47 100644 --- a/stdlib/2/datetime.pyi +++ b/stdlib/2/datetime.pyi @@ -38,7 +38,7 @@ class date(object): def day(self) -> int: ... def ctime(self) -> str: ... - def strftime(self, fmt: str) -> str: ... + def strftime(self, fmt: Union[str, unicode]) -> str: ... def __format__(self, fmt: Union[str, unicode]) -> str: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... @@ -83,7 +83,7 @@ class time: def __gt__(self, other: time) -> bool: ... def __hash__(self) -> int: ... def isoformat(self) -> str: ... - def strftime(self, fmt: str) -> str: ... + def strftime(self, fmt: Union[str, unicode]) -> str: ... def __format__(self, fmt: str) -> str: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... @@ -177,7 +177,7 @@ class datetime(object): def utcnow(cls) -> datetime: ... @classmethod def combine(cls, date: date, time: time) -> datetime: ... - def strftime(self, fmt: str) -> str: ... + def strftime(self, fmt: Union[str, unicode]) -> str: ... def __format__(self, fmt: str) -> str: ... def toordinal(self) -> int: ... def timetuple(self) -> struct_time: ... @@ -193,7 +193,7 @@ class datetime(object): def ctime(self) -> str: ... def isoformat(self, sep: str = ...) -> str: ... @classmethod - def strptime(cls, date_string: str, format: str) -> datetime: ... + def strptime(cls, date_string: Union[str, unicode], format: Union[str, unicode]) -> datetime: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... def dst(self) -> Optional[int]: ... diff --git a/stdlib/2/decimal.pyi b/stdlib/2/decimal.pyi index ce4d586ba..7d51c8fda 100644 --- a/stdlib/2/decimal.pyi +++ b/stdlib/2/decimal.pyi @@ -54,7 +54,7 @@ def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = None) -> _ContextManager: ... class Decimal(SupportsAbs[Decimal], SupportsFloat, SupportsInt): - def __init__(cls, value: Union[_Decimal, float, str, + def __init__(cls, value: Union[_Decimal, float, str, unicode, Tuple[int, Sequence[int], int]] = ..., context: Context = ...) -> None: ... @classmethod