From 37f4c4e6bea3b3f7b721f6e043fab2f07f0d54ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Hanuszczak?= Date: Wed, 23 Jan 2019 13:51:08 +0100 Subject: [PATCH 1/5] Make `NamedTuple` accept `AnyStr` names (#2761). --- stdlib/2/typing.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index b028769a7e70..ac66a1964a59 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -457,7 +457,8 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] - def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ..., *, + def __init__(self, typename: AnyStr, + fields: Iterable[Tuple[AnyStr, Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... @classmethod From 1197a69ae547b848545159996e6f1ea778c69c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Hanuszczak?= Date: Wed, 23 Jan 2019 22:20:25 +0100 Subject: [PATCH 2/5] Use `Union[str, unicode]` instead of `AnyStr`. --- stdlib/2/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index ac66a1964a59..27ab0ac01214 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -457,8 +457,8 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] - def __init__(self, typename: AnyStr, - fields: Iterable[Tuple[AnyStr, Any]] = ..., *, + def __init__(self, typename: Union[str, unicode], + fields: Iterable[Tuple[Union[str, unicode], Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... @classmethod From 5670566507754382826cdbac1e7c0ed5e0cf3e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Hanuszczak?= Date: Sat, 9 Feb 2019 17:57:39 +0100 Subject: [PATCH 3/5] Use `Text` rather than `unicode`. --- stdlib/2/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index 27ab0ac01214..f7a6d157caac 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -457,8 +457,8 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] - def __init__(self, typename: Union[str, unicode], - fields: Iterable[Tuple[Union[str, unicode], Any]] = ..., *, + def __init__(self, typename: Union[str, Text], + fields: Iterable[Tuple[Union[str, Text], Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... @classmethod From 8efaa458b91aa4878ae6dc7e3c2b2d6396b8248a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Hanuszczak?= Date: Sat, 9 Feb 2019 18:10:00 +0100 Subject: [PATCH 4/5] Use `Text` instead of `Union[str, Text]`. --- stdlib/2/typing.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index f7a6d157caac..ff78d1a4686f 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -457,8 +457,8 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] - def __init__(self, typename: Union[str, Text], - fields: Iterable[Tuple[Union[str, Text], Any]] = ..., *, + def __init__(self, typename: Text, + fields: Iterable[Tuple[Text, Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... @classmethod From fd024111b0961a295c00fb371bc4b514f536891a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Hanuszczak?= Date: Sat, 9 Feb 2019 18:11:47 +0100 Subject: [PATCH 5/5] Revert line break. --- stdlib/2/typing.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index ff78d1a4686f..7049d10bb75e 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -457,8 +457,7 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] - def __init__(self, typename: Text, - fields: Iterable[Tuple[Text, Any]] = ..., *, + def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... @classmethod