mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
AnyStr cleanup (#5487)
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs. * Add StrOrBytesPath as preferred alias for AnyPath. * Replace all remaining AnyPath instances with StrOrBytesPath. * Mark AnyPath as obsolete. Part of #5470
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
from _typeshed import AnyPath, BytesPath, StrPath, SupportsLessThanT
|
||||
from typing import List, Sequence, Tuple, Union, overload
|
||||
from _typeshed import SupportsLessThanT
|
||||
from typing import List, Sequence, Text, Tuple, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
# All overloads can return empty string. Ideally, Literal[""] would be a valid
|
||||
# Iterable[T], so that Union[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[StrPath]) -> str: ... # type: ignore
|
||||
def commonprefix(m: Sequence[Text]) -> str: ... # type: ignore
|
||||
@overload
|
||||
def commonprefix(m: Sequence[BytesPath]) -> Union[bytes, Literal[""]]: ... # type: ignore
|
||||
def commonprefix(m: Sequence[str]) -> Union[str, Literal[""]]: ... # type: ignore
|
||||
@overload
|
||||
def commonprefix(m: Sequence[List[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ...
|
||||
@overload
|
||||
def commonprefix(m: Sequence[Tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ...
|
||||
def exists(path: AnyPath) -> bool: ...
|
||||
def getsize(filename: AnyPath) -> int: ...
|
||||
def isfile(path: AnyPath) -> bool: ...
|
||||
def isdir(s: AnyPath) -> bool: ...
|
||||
def exists(path: Text) -> bool: ...
|
||||
def getsize(filename: Text) -> int: ...
|
||||
def isfile(path: Text) -> bool: ...
|
||||
def isdir(s: Text) -> bool: ...
|
||||
|
||||
# These return float if os.stat_float_times() == True,
|
||||
# but int is a subclass of float.
|
||||
def getatime(filename: AnyPath) -> float: ...
|
||||
def getmtime(filename: AnyPath) -> float: ...
|
||||
def getctime(filename: AnyPath) -> float: ...
|
||||
def getatime(filename: Text) -> float: ...
|
||||
def getmtime(filename: Text) -> float: ...
|
||||
def getctime(filename: Text) -> float: ...
|
||||
|
||||
Reference in New Issue
Block a user