From 30269e1cedd2055b4df0473b2a6275830bc69522 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Wed, 19 Jan 2022 21:41:55 -0800 Subject: [PATCH 1/4] Fix strtobool type annotation Problem: strtobool returns either 0 or 1, not bool. Solution: Fix type annotation. --- stdlib/@python2/distutils/util.pyi | 4 ++-- stdlib/distutils/util.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index 6f5e755f5c35..9059377d2d4c 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Mapping +from typing import Any, Callable, Literal, Mapping, Union def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -9,7 +9,7 @@ def split_quoted(s: str) -> list[str]: ... def execute( func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... -def strtobool(val: str) -> bool: ... +def strtobool(val: str) -> Union[Literal[0], Literal[1]]: ... def byte_compile( py_files: list[str], optimize: int = ..., diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 03ee0185cac4..7860832406e7 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any +from typing import Any, Literal, Union def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -11,7 +11,7 @@ def split_quoted(s: str) -> list[str]: ... def execute( func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... -def strtobool(val: str) -> bool: ... +def strtobool(val: str) -> Union[Literal[0], Literal[1]]: ... def byte_compile( py_files: list[str], optimize: int = ..., From bc0757f405df2484f6930126ad9e22a2ceba1f9d Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Wed, 19 Jan 2022 21:47:15 -0800 Subject: [PATCH 2/4] Fix syntax Co-authored-by: Jelle Zijlstra --- stdlib/@python2/distutils/util.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index 9059377d2d4c..4a21246bc1fc 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -9,7 +9,7 @@ def split_quoted(s: str) -> list[str]: ... def execute( func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... -def strtobool(val: str) -> Union[Literal[0], Literal[1]]: ... +def strtobool(val: str) -> Literal[0, 1]: ... def byte_compile( py_files: list[str], optimize: int = ..., From 6322f7f4e5b1e22ba959d94b00acee4a9e8391d9 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Wed, 19 Jan 2022 21:48:27 -0800 Subject: [PATCH 3/4] Remove Union --- stdlib/@python2/distutils/util.pyi | 2 +- stdlib/distutils/util.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index 4a21246bc1fc..0bc98b42b87e 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Literal, Mapping, Union +from typing import Any, Callable, Literal, Mapping def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 7860832406e7..237d4da8bd0e 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Literal, Union +from typing import Any, Literal def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... @@ -11,7 +11,7 @@ def split_quoted(s: str) -> list[str]: ... def execute( func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... -def strtobool(val: str) -> Union[Literal[0], Literal[1]]: ... +def strtobool(val: str) -> Literal[0, 1]: ... def byte_compile( py_files: list[str], optimize: int = ..., From 9caf26421e1cf436188ef051c23f84080d9b41ac Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Wed, 19 Jan 2022 21:50:13 -0800 Subject: [PATCH 4/4] Use Literal from typing_extensions --- stdlib/@python2/distutils/util.pyi | 3 ++- stdlib/distutils/util.pyi | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index 0bc98b42b87e..935a695e58db 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Literal, Mapping +from typing import Any, Callable, Mapping +from typing_extensions import Literal def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 237d4da8bd0e..22d982e6949d 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,6 +1,7 @@ from _typeshed import StrPath from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Literal +from typing import Any +from typing_extensions import Literal def get_platform() -> str: ... def convert_path(pathname: str) -> str: ...