From e9b0a6d4a4886f55599e294a72ab1d40e0168ea9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 25 May 2022 20:09:47 -0700 Subject: [PATCH] posixpath: Rearrange overloads I think this may remove the false positives from #7939's mypy-primer output. --- stdlib/posixpath.pyi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index 8d880a072dfb..fb2fcaccac96 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -72,9 +72,9 @@ devnull: LiteralString # Overloads are necessary to work around python/mypy#3644. @overload -def abspath(path: PathLike[AnyStr]) -> AnyStr: ... +def abspath(path: StrPath) -> str: ... @overload -def abspath(path: AnyStr) -> AnyStr: ... +def abspath(path: BytesPath) -> bytes: ... @overload def basename(p: PathLike[AnyStr]) -> AnyStr: ... @overload @@ -84,13 +84,13 @@ def dirname(p: PathLike[AnyStr]) -> AnyStr: ... @overload def dirname(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ... @overload -def expanduser(path: PathLike[AnyStr]) -> AnyStr: ... +def expanduser(path: StrPath) -> str: ... @overload -def expanduser(path: AnyStr) -> AnyStr: ... +def expanduser(path: BytesPath) -> bytes: ... @overload -def expandvars(path: PathLike[AnyStr]) -> AnyStr: ... +def expandvars(path: StrPath) -> str: ... @overload -def expandvars(path: AnyStr) -> AnyStr: ... +def expandvars(path: BytesPath) -> bytes: ... @overload def normcase(s: PathLike[AnyStr]) -> AnyStr: ... @overload @@ -118,15 +118,15 @@ def join(__a: BytesPath, *paths: BytesPath) -> bytes: ... if sys.version_info >= (3, 10): @overload - def realpath(filename: PathLike[AnyStr], *, strict: bool = ...) -> AnyStr: ... + def realpath(filename: StrPath, *, strict: bool = ...) -> str: ... @overload - def realpath(filename: AnyStr, *, strict: bool = ...) -> AnyStr: ... + def realpath(filename: BytesPath, *, strict: bool = ...) -> bytes: ... else: @overload - def realpath(filename: PathLike[AnyStr]) -> AnyStr: ... + def realpath(filename: StrPath) -> str: ... @overload - def realpath(filename: AnyStr) -> AnyStr: ... + def realpath(filename: BytesPath) -> bytes: ... @overload def relpath(path: LiteralString, start: LiteralString | None = ...) -> LiteralString: ...