mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Redo PathLike without importing os into builtins.
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import (
|
||||
Sequence, MutableSequence, Mapping, MutableMapping, Tuple, List, Any, Dict, Callable, Generic,
|
||||
Set, AbstractSet, FrozenSet, MutableSet, Sized, Reversible, SupportsInt, SupportsFloat,
|
||||
SupportsBytes, SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView,
|
||||
ByteString, Optional
|
||||
ByteString, Optional, AnyStr,
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from types import TracebackType
|
||||
@@ -799,8 +799,13 @@ def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ...
|
||||
def oct(i: int) -> str: ... # TODO __index__
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from pathlib import Path
|
||||
def open(file: Union[str, bytes, int, Path], mode: str = 'r', buffering: int = -1, encoding: str = None,
|
||||
# This class is to be exported as PathLike from os,
|
||||
# but we define it here as _PathLike to avoid import cycle issues.
|
||||
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
|
||||
class _PathLike:
|
||||
def __fspath__(self) -> AnyStr: ...
|
||||
|
||||
def open(file: Union[str, bytes, int, _PathLike], mode: str = 'r', buffering: int = -1, encoding: str = None,
|
||||
errors: str = None, newline: str = None, closefd: bool = ...) -> IO[Any]: ...
|
||||
else:
|
||||
def open(file: Union[str, bytes, int], mode: str = 'r', buffering: int = -1, encoding: str = None,
|
||||
|
||||
@@ -114,8 +114,7 @@ TMP_MAX = 0 # Undocumented, but used by tempfile
|
||||
|
||||
# ----- os classes (structures) -----
|
||||
if sys.version_info >= (3, 6):
|
||||
class PathLike:
|
||||
def __fspath__(self) -> AnyStr: ...
|
||||
from builtins import _PathLike as PathLike # See comment in builtins
|
||||
|
||||
_PathType = Union[bytes, Text]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user