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

@@ -2,7 +2,7 @@ import os
from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRichComparisonT
from collections.abc import Sequence
from typing import overload
from typing_extensions import Literal
from typing_extensions import Literal, LiteralString
__all__ = [
"commonprefix",
@@ -22,6 +22,8 @@ __all__ = [
# Iterable[T], so that list[T] | Literal[""] could be used as a return
# type. But because this only works when T is str, we need Sequence[T] instead.
@overload
def commonprefix(m: Sequence[LiteralString]) -> LiteralString: ...
@overload
def commonprefix(m: Sequence[StrPath]) -> str: ...
@overload
def commonprefix(m: Sequence[BytesPath]) -> bytes | Literal[""]: ...