From beaff809b6af510c194b29b6d56d79b5a9f44963 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Fri, 18 May 2018 13:59:37 -0700 Subject: [PATCH 1/2] Rearrange overloads to account for optional arguments Basically, the same thing as [my previous pull request][0], except the fixes are now focusing on functions with overlapping argument counts. [0]: https://github.com/python/typeshed/pull/2138 --- stdlib/2/os/path.pyi | 4 ++-- stdlib/2and3/sysconfig.pyi | 2 +- third_party/3/pkg_resources.pyi | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/2/os/path.pyi b/stdlib/2/os/path.pyi index bd32c5e6c63c..1f57575af67b 100644 --- a/stdlib/2/os/path.pyi +++ b/stdlib/2/os/path.pyi @@ -140,9 +140,9 @@ else: def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... @overload -def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... # type: ignore +def relpath(path: _BytesPath, start: _BytesPath) -> bytes: ... # type: ignore @overload -def relpath(path: _BytesPath, start: _BytesPath) -> bytes: ... +def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... def samefile(path1: _PathType, path2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... diff --git a/stdlib/2and3/sysconfig.pyi b/stdlib/2and3/sysconfig.pyi index 844caa851203..5d6c9cb19c8a 100644 --- a/stdlib/2and3/sysconfig.pyi +++ b/stdlib/2and3/sysconfig.pyi @@ -5,7 +5,7 @@ from typing import overload, Any, Dict, IO, List, Optional, Tuple, Union @overload def get_config_vars() -> Dict[str, Any]: ... @overload -def get_config_vars(*args: str) -> List[Any]: ... +def get_config_vars(arg: str, *args: str) -> List[Any]: ... def get_config_var(name: str) -> Optional[str]: ... def get_scheme_names() -> Tuple[str, ...]: ... def get_path_names() -> Tuple[str, ...]: ... diff --git a/third_party/3/pkg_resources.pyi b/third_party/3/pkg_resources.pyi index b31ea6d6ffdd..fe0c10159f80 100644 --- a/third_party/3/pkg_resources.pyi +++ b/third_party/3/pkg_resources.pyi @@ -108,7 +108,7 @@ def get_entry_info(dist: _EPDistType, group: str, @overload def get_entry_map(dist: _EPDistType) -> Dict[str, Dict[str, EntryPoint]]: ... @overload -def get_entry_map(dist: _EPDistType, group: str = ...) -> Dict[str, EntryPoint]: ... +def get_entry_map(dist: _EPDistType, group: str) -> Dict[str, EntryPoint]: ... class EntryPoint: name = ... # type: str @@ -174,7 +174,7 @@ class Distribution(IResourceProvider, IMetadataProvider): def get_entry_map(dist: _EPDistType) \ -> Dict[str, Dict[str, EntryPoint]]: ... @overload - def get_entry_map(dist: _EPDistType, group: str = ...) \ + def get_entry_map(dist: _EPDistType, group: str) \ -> Dict[str, EntryPoint]: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> None: ... From 866240efe78c72fdeac0651961b3c2916f780705 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Fri, 18 May 2018 16:48:24 -0700 Subject: [PATCH 2/2] Mirror changes in Python 2's os.path to Python 3's --- stdlib/3/os/path.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/os/path.pyi b/stdlib/3/os/path.pyi index 2cb23811ce5f..b93318bb47a6 100644 --- a/stdlib/3/os/path.pyi +++ b/stdlib/3/os/path.pyi @@ -140,9 +140,9 @@ else: def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... @overload -def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... # type: ignore +def relpath(path: _BytesPath, start: _BytesPath) -> bytes: ... # type: ignore @overload -def relpath(path: _BytesPath, start: _BytesPath) -> bytes: ... +def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... def samefile(path1: _PathType, path2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ...