Add LiteralString overloads to path module (#7727)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Graham Bleaney
2022-05-25 11:52:52 -04:00
committed by GitHub
parent ac9efd8573
commit cb5b31cf15
4 changed files with 34 additions and 19 deletions

View File

@@ -43,6 +43,7 @@ from posixpath import (
supports_unicode_filenames as supports_unicode_filenames,
)
from typing import AnyStr, overload
from typing_extensions import LiteralString
if sys.version_info >= (3, 7) or sys.platform != "win32":
__all__ = [
@@ -130,12 +131,14 @@ else:
def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated
altsep: str
altsep: LiteralString
# First parameter is not actually pos-only,
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
# as the parameter name is different in posixpath.join()
@overload
def join(__path: LiteralString, *paths: LiteralString) -> LiteralString: ...
@overload
def join(__path: StrPath, *paths: StrPath) -> str: ...
@overload
def join(__path: BytesPath, *paths: BytesPath) -> bytes: ...