From 4ccc757d1ad8a1b791f3105eb437b046c386528e Mon Sep 17 00:00:00 2001 From: Shantanu Date: Tue, 17 Mar 2020 07:05:23 -0700 Subject: [PATCH] macpath: fix arg names, remove nonexistent functions (#3853) * macpath: fix arg names * macpath: remove commonpath, relpath --- stdlib/2and3/macpath.pyi | 97 ++++++++++++------------------ tests/stubtest_whitelists/py35.txt | 21 ------- tests/stubtest_whitelists/py36.txt | 21 ------- tests/stubtest_whitelists/py37.txt | 21 ------- 4 files changed, 38 insertions(+), 122 deletions(-) diff --git a/stdlib/2and3/macpath.pyi b/stdlib/2and3/macpath.pyi index 324fc7b31..edcc31ddc 100644 --- a/stdlib/2and3/macpath.pyi +++ b/stdlib/2and3/macpath.pyi @@ -38,13 +38,13 @@ if sys.version_info < (3, 8): @overload def abspath(path: AnyStr) -> AnyStr: ... @overload - def basename(path: _PathLike[AnyStr]) -> AnyStr: ... + def basename(s: _PathLike[AnyStr]) -> AnyStr: ... @overload - def basename(path: AnyStr) -> AnyStr: ... + def basename(s: AnyStr) -> AnyStr: ... @overload - def dirname(path: _PathLike[AnyStr]) -> AnyStr: ... + def dirname(s: _PathLike[AnyStr]) -> AnyStr: ... @overload - def dirname(path: AnyStr) -> AnyStr: ... + def dirname(s: AnyStr) -> AnyStr: ... @overload def expanduser(path: _PathLike[AnyStr]) -> AnyStr: ... @overload @@ -58,44 +58,28 @@ if sys.version_info < (3, 8): @overload def normcase(path: AnyStr) -> AnyStr: ... @overload - def normpath(path: _PathLike[AnyStr]) -> AnyStr: ... + def normpath(s: _PathLike[AnyStr]) -> AnyStr: ... @overload - def normpath(path: AnyStr) -> AnyStr: ... - if sys.platform == 'win32': - @overload - def realpath(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def realpath(path: AnyStr) -> AnyStr: ... - else: - @overload - def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def realpath(filename: AnyStr) -> AnyStr: ... + def normpath(s: AnyStr) -> AnyStr: ... + @overload + def realpath(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def realpath(path: AnyStr) -> AnyStr: ... else: def abspath(path: AnyStr) -> AnyStr: ... - def basename(path: AnyStr) -> AnyStr: ... - def dirname(path: AnyStr) -> AnyStr: ... + def basename(s: AnyStr) -> AnyStr: ... + def dirname(s: AnyStr) -> AnyStr: ... def expanduser(path: AnyStr) -> AnyStr: ... def expandvars(path: AnyStr) -> AnyStr: ... def normcase(path: AnyStr) -> AnyStr: ... - def normpath(path: AnyStr) -> AnyStr: ... - if sys.platform == 'win32': - def realpath(path: AnyStr) -> AnyStr: ... - else: - def realpath(filename: AnyStr) -> AnyStr: ... - - if sys.version_info >= (3, 6): - # In reality it returns str for sequences of _StrPath and bytes for sequences - # of _BytesPath, but mypy does not accept such a signature. - def commonpath(paths: Sequence[_PathType]) -> Any: ... - elif sys.version_info >= (3, 5): - def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ... + def normpath(s: AnyStr) -> AnyStr: ... + def realpath(path: AnyStr) -> AnyStr: ... # NOTE: Empty lists results in '' (str) regardless of contained type. # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes # So, fall back to Any - def commonprefix(list: Sequence[_PathType]) -> Any: ... + def commonprefix(m: Sequence[_PathType]) -> Any: ... if sys.version_info >= (3, 3): def exists(path: Union[_PathType, int]) -> bool: ... @@ -105,16 +89,16 @@ if sys.version_info < (3, 8): # These return float if os.stat_float_times() == True, # but int is a subclass of float. - def getatime(path: _PathType) -> float: ... - def getmtime(path: _PathType) -> float: ... - def getctime(path: _PathType) -> float: ... + def getatime(filename: _PathType) -> float: ... + def getmtime(filename: _PathType) -> float: ... + def getctime(filename: _PathType) -> float: ... - def getsize(path: _PathType) -> int: ... - def isabs(path: _PathType) -> bool: ... + def getsize(filename: _PathType) -> int: ... + def isabs(s: _PathType) -> bool: ... def isfile(path: _PathType) -> bool: ... - def isdir(path: _PathType) -> bool: ... - def islink(path: _PathType) -> bool: ... - def ismount(path: _PathType) -> bool: ... + def isdir(s: _PathType) -> bool: ... + def islink(s: _PathType) -> bool: ... + def ismount(s: _PathType) -> bool: ... if sys.version_info < (3, 0): # Make sure signatures are disjunct, and allow combinations of bytes and unicode. @@ -132,40 +116,35 @@ if sys.version_info < (3, 8): @overload def join(__p1: Text, *p: _PathType) -> Text: ... elif sys.version_info >= (3, 6): - # Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway. + # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. @overload - def join(path: _StrPath, *paths: _StrPath) -> Text: ... + def join(s: _StrPath, *paths: _StrPath) -> Text: ... @overload - def join(path: _BytesPath, *paths: _BytesPath) -> bytes: ... + def join(s: _BytesPath, *paths: _BytesPath) -> bytes: ... else: - def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... + def join(s: AnyStr, *paths: AnyStr) -> AnyStr: ... - @overload - def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ... - @overload - def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... - - def samefile(path1: _PathType, path2: _PathType) -> bool: ... + def samefile(f1: _PathType, f2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... - def samestat(stat1: os.stat_result, stat2: os.stat_result) -> bool: ... + def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... if sys.version_info >= (3, 6): @overload - def split(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + def split(s: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... @overload - def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... @overload - def splitdrive(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + def splitdrive(p: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... @overload - def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... @overload - def splitext(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + def splitext(p: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... @overload - def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... else: - def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... if sys.version_info < (3,): def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/tests/stubtest_whitelists/py35.txt b/tests/stubtest_whitelists/py35.txt index bd9b5cfc7..069fd79cc 100644 --- a/tests/stubtest_whitelists/py35.txt +++ b/tests/stubtest_whitelists/py35.txt @@ -39,27 +39,6 @@ json.dump json.dumps json.load json.loads -macpath.basename -macpath.commonpath -macpath.commonprefix -macpath.dirname -macpath.getatime -macpath.getctime -macpath.getmtime -macpath.getsize -macpath.isabs -macpath.isdir -macpath.islink -macpath.ismount -macpath.join -macpath.normpath -macpath.realpath -macpath.relpath -macpath.samefile -macpath.samestat -macpath.split -macpath.splitdrive -macpath.splitext mmap.ACCESS_DEFAULT multiprocessing.context.BaseContext.reducer multiprocessing.shared_memory diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index f12966241..778563040 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -42,27 +42,6 @@ io.StringIO.readline ipaddress._BaseNetwork.__init__ json.loads logging.handlers.MemoryHandler.__init__ -macpath.basename -macpath.commonpath -macpath.commonprefix -macpath.dirname -macpath.getatime -macpath.getctime -macpath.getmtime -macpath.getsize -macpath.isabs -macpath.isdir -macpath.islink -macpath.ismount -macpath.join -macpath.normpath -macpath.realpath -macpath.relpath -macpath.samefile -macpath.samestat -macpath.split -macpath.splitdrive -macpath.splitext mmap.ACCESS_DEFAULT multiprocessing.shared_memory os.utime diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index feaaea552..4e5636538 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -58,27 +58,6 @@ importlib.metadata ipaddress._BaseNetwork.__init__ json.loads logging.handlers.MemoryHandler.__init__ -macpath.basename -macpath.commonpath -macpath.commonprefix -macpath.dirname -macpath.getatime -macpath.getctime -macpath.getmtime -macpath.getsize -macpath.isabs -macpath.isdir -macpath.islink -macpath.ismount -macpath.join -macpath.normpath -macpath.realpath -macpath.relpath -macpath.samefile -macpath.samestat -macpath.split -macpath.splitdrive -macpath.splitext macurl2path multiprocessing.shared_memory os.utime