mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +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,6 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
from _typeshed import AnyPath, BytesPath, StrPath
|
||||
from genericpath import exists as exists
|
||||
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload
|
||||
|
||||
@@ -39,20 +38,20 @@ else:
|
||||
# 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(m: Sequence[AnyPath]) -> Any: ...
|
||||
def lexists(path: AnyPath) -> bool: ...
|
||||
def commonprefix(m: Sequence[Text]) -> Any: ...
|
||||
def lexists(path: 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 getsize(filename: AnyPath) -> int: ...
|
||||
def isabs(s: AnyPath) -> bool: ...
|
||||
def isfile(path: AnyPath) -> bool: ...
|
||||
def isdir(s: AnyPath) -> bool: ...
|
||||
def islink(path: AnyPath) -> bool: ...
|
||||
def ismount(path: AnyPath) -> bool: ...
|
||||
def getatime(filename: Text) -> float: ...
|
||||
def getmtime(filename: Text) -> float: ...
|
||||
def getctime(filename: Text) -> float: ...
|
||||
def getsize(filename: Text) -> int: ...
|
||||
def isabs(s: Text) -> bool: ...
|
||||
def isfile(path: Text) -> bool: ...
|
||||
def isdir(s: Text) -> bool: ...
|
||||
def islink(path: Text) -> bool: ...
|
||||
def ismount(path: Text) -> bool: ...
|
||||
|
||||
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
|
||||
# (Since Python 2 allows that, too)
|
||||
@@ -61,18 +60,18 @@ def ismount(path: AnyPath) -> bool: ...
|
||||
@overload
|
||||
def join(__p1: bytes, *p: bytes) -> bytes: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
|
||||
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
|
||||
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
|
||||
def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: Text, *p: AnyPath) -> Text: ...
|
||||
def join(__p1: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
|
||||
def relpath(path: str, start: Optional[str] = ...) -> str: ...
|
||||
@overload
|
||||
def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
|
||||
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
|
||||
def relpath(path: Text, start: Optional[Text] = ...) -> Text: ...
|
||||
def samefile(f1: Text, f2: Text) -> bool: ...
|
||||
def sameopenfile(fp1: int, fp2: int) -> bool: ...
|
||||
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...
|
||||
def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
|
||||
Reference in New Issue
Block a user