mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-13 05:31:43 +08:00
use _typeshed's Path aliases (#4214)
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
from typing import List, Optional, Union
|
||||
from _typeshed import AnyPath
|
||||
from typing import List, Optional
|
||||
from types import FrameType
|
||||
from . import tasks
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike
|
||||
_PathType = Union[bytes, str, _PathLike]
|
||||
else:
|
||||
_PathType = Union[bytes, str]
|
||||
|
||||
def _task_repr_info(task: tasks.Task) -> List[str]: ... # undocumented
|
||||
def _task_get_stack(task: tasks.Task, limit: Optional[int]) -> List[FrameType]: ... # undocumented
|
||||
def _task_print_stack(task: tasks.Task, limit: Optional[int], file: _PathType): ... # undocumented
|
||||
def _task_print_stack(task: tasks.Task, limit: Optional[int], file: AnyPath): ... # undocumented
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import sys
|
||||
from socket import socket
|
||||
from typing import Any, Mapping, Optional, Union
|
||||
from typing import Any, Mapping, Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
from . import base_events, constants, events, futures, streams, transports
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from os import PathLike
|
||||
_Path = Union[str, PathLike[str]]
|
||||
else:
|
||||
_Path = str
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):
|
||||
|
||||
def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ...
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import selectors
|
||||
import sys
|
||||
from socket import socket
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Optional
|
||||
|
||||
from . import base_events, events
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from os import PathLike
|
||||
_Path = Union[str, PathLike[str]]
|
||||
else:
|
||||
_Path = str
|
||||
from . import base_events
|
||||
|
||||
class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||
def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ...
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
# Stubs for compileall (Python 3)
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Optional, Union, Pattern
|
||||
from _typeshed import AnyPath
|
||||
from typing import Any, Optional, Pattern
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
_Path = Union[str, bytes]
|
||||
_SuccessType = bool
|
||||
else:
|
||||
_Path = Union[str, bytes, os.PathLike]
|
||||
_SuccessType = int
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
@@ -16,9 +12,9 @@ if sys.version_info >= (3, 7):
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def compile_dir(
|
||||
dir: _Path,
|
||||
dir: AnyPath,
|
||||
maxlevels: Optional[int] = ...,
|
||||
ddir: Optional[_Path] = ...,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
@@ -27,13 +23,13 @@ if sys.version_info >= (3, 9):
|
||||
workers: int = ...,
|
||||
invalidation_mode: Optional[PycInvalidationMode] = ...,
|
||||
*,
|
||||
stripdir: Optional[str] = ..., # TODO: change to Optional[_Path] once https://bugs.python.org/issue40447 is resolved
|
||||
prependdir: Optional[_Path] = ...,
|
||||
limit_sl_dest: Optional[_Path] = ...,
|
||||
stripdir: Optional[str] = ..., # TODO: change to Optional[AnyPath] once https://bugs.python.org/issue40447 is resolved
|
||||
prependdir: Optional[AnyPath] = ...,
|
||||
limit_sl_dest: Optional[AnyPath] = ...,
|
||||
) -> _SuccessType: ...
|
||||
def compile_file(
|
||||
fullname: _Path,
|
||||
ddir: Optional[_Path] = ...,
|
||||
fullname: AnyPath,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
@@ -41,15 +37,15 @@ if sys.version_info >= (3, 9):
|
||||
optimize: int = ...,
|
||||
invalidation_mode: Optional[PycInvalidationMode] = ...,
|
||||
*,
|
||||
stripdir: Optional[str] = ..., # TODO: change to Optional[_Path] once https://bugs.python.org/issue40447 is resolved
|
||||
prependdir: Optional[_Path] = ...,
|
||||
limit_sl_dest: Optional[_Path] = ...,
|
||||
stripdir: Optional[str] = ..., # TODO: change to Optional[AnyPath] once https://bugs.python.org/issue40447 is resolved
|
||||
prependdir: Optional[AnyPath] = ...,
|
||||
limit_sl_dest: Optional[AnyPath] = ...,
|
||||
) -> _SuccessType: ...
|
||||
elif sys.version_info >= (3, 7):
|
||||
def compile_dir(
|
||||
dir: _Path,
|
||||
dir: AnyPath,
|
||||
maxlevels: int = ...,
|
||||
ddir: Optional[_Path] = ...,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
@@ -59,8 +55,8 @@ elif sys.version_info >= (3, 7):
|
||||
invalidation_mode: Optional[PycInvalidationMode] = ...,
|
||||
) -> _SuccessType: ...
|
||||
def compile_file(
|
||||
fullname: _Path,
|
||||
ddir: Optional[_Path] = ...,
|
||||
fullname: AnyPath,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
@@ -72,9 +68,9 @@ elif sys.version_info >= (3, 7):
|
||||
else:
|
||||
# rx can be any object with a 'search' method; once we have Protocols we can change the type
|
||||
def compile_dir(
|
||||
dir: _Path,
|
||||
dir: AnyPath,
|
||||
maxlevels: int = ...,
|
||||
ddir: Optional[_Path] = ...,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
@@ -83,8 +79,8 @@ else:
|
||||
workers: int = ...,
|
||||
) -> _SuccessType: ...
|
||||
def compile_file(
|
||||
fullname: _Path,
|
||||
ddir: Optional[_Path] = ...,
|
||||
fullname: AnyPath,
|
||||
ddir: Optional[AnyPath] = ...,
|
||||
force: bool = ...,
|
||||
rx: Optional[Pattern[Any]] = ...,
|
||||
quiet: int = ...,
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
# Based on http://docs.python.org/3.5/library/configparser.html and on
|
||||
# reading configparser.py.
|
||||
|
||||
from _typeshed import AnyPath, StrPath
|
||||
import sys
|
||||
from typing import (AbstractSet, MutableMapping, Mapping, Dict, Sequence, List,
|
||||
Union, Iterable, Iterator, Callable, Any, IO, overload,
|
||||
Optional, Pattern, Type, TypeVar, ClassVar)
|
||||
# Types only used in type comments only
|
||||
from typing import Optional, Tuple # noqa
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from os import PathLike
|
||||
Optional, Pattern, Type, TypeVar, ClassVar, Tuple)
|
||||
|
||||
# Internal type aliases
|
||||
_section = Mapping[str, str]
|
||||
@@ -19,11 +12,9 @@ _converters = Dict[str, _converter]
|
||||
_T = TypeVar('_T')
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_Path = Union[str, bytes, PathLike[str]]
|
||||
elif sys.version_info >= (3, 6):
|
||||
_Path = Union[str, PathLike[str]]
|
||||
_Path = AnyPath
|
||||
else:
|
||||
_Path = str
|
||||
_Path = StrPath
|
||||
|
||||
DEFAULTSECT: str
|
||||
MAX_INTERPOLATION_DEPTH: int
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import sys
|
||||
from typing import overload, Any, Container, IO, Iterable, Optional, Sequence, Type, TypeVar, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from os import PathLike
|
||||
_Path = Union[str, PathLike[str]]
|
||||
else:
|
||||
_Path = str
|
||||
from _typeshed import StrPath
|
||||
from typing_extensions import Literal
|
||||
|
||||
class NullTranslations:
|
||||
def __init__(self, fp: Optional[IO[str]] = ...) -> None: ...
|
||||
@@ -35,25 +26,25 @@ class GNUTranslations(NullTranslations):
|
||||
CONTEXT: str
|
||||
VERSIONS: Sequence[int]
|
||||
|
||||
def find(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
def find(domain: str, localedir: Optional[StrPath] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
all: bool = ...) -> Any: ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
@overload
|
||||
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
def translation(domain: str, localedir: Optional[StrPath] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
class_: None = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ...
|
||||
@overload
|
||||
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
def translation(domain: str, localedir: Optional[StrPath] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
class_: Type[_T] = ..., fallback: Literal[False] = ..., codeset: Optional[str] = ...) -> _T: ...
|
||||
@overload
|
||||
def translation(domain: str, localedir: Optional[_Path] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
def translation(domain: str, localedir: Optional[StrPath] = ..., languages: Optional[Iterable[str]] = ...,
|
||||
class_: Type[_T] = ..., fallback: Literal[True] = ..., codeset: Optional[str] = ...) -> Any: ...
|
||||
|
||||
def install(domain: str, localedir: Optional[_Path] = ..., codeset: Optional[str] = ...,
|
||||
def install(domain: str, localedir: Optional[StrPath] = ..., codeset: Optional[str] = ...,
|
||||
names: Optional[Container[str]] = ...) -> None: ...
|
||||
|
||||
def textdomain(domain: Optional[str] = ...) -> str: ...
|
||||
def bindtextdomain(domain: str, localedir: Optional[_Path] = ...) -> str: ...
|
||||
def bindtextdomain(domain: str, localedir: Optional[StrPath] = ...) -> str: ...
|
||||
def bind_textdomain_codeset(domain: str, codeset: Optional[str] = ...) -> str: ...
|
||||
def dgettext(domain: str, message: str) -> str: ...
|
||||
def ldgettext(domain: str, message: str) -> str: ...
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
import sys
|
||||
import zlib
|
||||
from os.path import _PathType
|
||||
from typing import IO, Optional, TextIO, Union, overload
|
||||
|
||||
import _compression
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
from _typeshed import AnyPath
|
||||
from typing_extensions import Literal
|
||||
|
||||
_OpenBinaryMode = Literal["r", "rb", "a", "ab", "w", "wb", "x", "xb"]
|
||||
_OpenTextMode = Literal["rt", "at", "wt", "xt"]
|
||||
|
||||
@overload
|
||||
def open(
|
||||
filename: Union[_PathType, IO[bytes]],
|
||||
filename: Union[AnyPath, IO[bytes]],
|
||||
mode: _OpenBinaryMode = ...,
|
||||
compresslevel: int = ...,
|
||||
encoding: None = ...,
|
||||
@@ -24,7 +19,7 @@ def open(
|
||||
) -> GzipFile: ...
|
||||
@overload
|
||||
def open(
|
||||
filename: _PathType,
|
||||
filename: AnyPath,
|
||||
mode: _OpenTextMode,
|
||||
compresslevel: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
@@ -33,7 +28,7 @@ def open(
|
||||
) -> TextIO: ...
|
||||
@overload
|
||||
def open(
|
||||
filename: Union[_PathType, IO[bytes]],
|
||||
filename: Union[AnyPath, IO[bytes]],
|
||||
mode: str,
|
||||
compresslevel: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
@@ -57,7 +52,7 @@ class GzipFile(_compression.BaseStream):
|
||||
fileobj: IO[bytes]
|
||||
def __init__(
|
||||
self,
|
||||
filename: Optional[_PathType] = ...,
|
||||
filename: Optional[AnyPath] = ...,
|
||||
mode: Optional[str] = ...,
|
||||
compresslevel: int = ...,
|
||||
fileobj: Optional[IO[bytes]] = ...,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Stubs for imp (Python 3.6)
|
||||
|
||||
import os
|
||||
import sys
|
||||
from _typeshed import StrPath
|
||||
import types
|
||||
from typing import Any, IO, List, Optional, Tuple, TypeVar, Union
|
||||
|
||||
@@ -13,11 +12,6 @@ from _imp import create_dynamic as create_dynamic
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
_Path = Union[str, os.PathLike[str]]
|
||||
else:
|
||||
_Path = str
|
||||
|
||||
SEARCH_ERROR: int
|
||||
PY_SOURCE: int
|
||||
PY_COMPILED: int
|
||||
@@ -32,21 +26,21 @@ IMP_HOOK: int
|
||||
def new_module(name: str) -> types.ModuleType: ...
|
||||
def get_magic() -> bytes: ...
|
||||
def get_tag() -> str: ...
|
||||
def cache_from_source(path: _Path, debug_override: Optional[bool] = ...) -> str: ...
|
||||
def source_from_cache(path: _Path) -> str: ...
|
||||
def cache_from_source(path: StrPath, debug_override: Optional[bool] = ...) -> str: ...
|
||||
def source_from_cache(path: StrPath) -> str: ...
|
||||
def get_suffixes() -> List[Tuple[str, str, int]]: ...
|
||||
|
||||
class NullImporter:
|
||||
def __init__(self, path: _Path) -> None: ...
|
||||
def __init__(self, path: StrPath) -> None: ...
|
||||
def find_module(self, fullname: Any) -> None: ...
|
||||
|
||||
# PathLike doesn't work for the pathname argument here
|
||||
def load_source(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ...
|
||||
def load_compiled(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ...
|
||||
def load_package(name: str, path: _Path) -> types.ModuleType: ...
|
||||
def load_package(name: str, path: StrPath) -> types.ModuleType: ...
|
||||
def load_module(name: str, file: IO[Any], filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def find_module(name: str, path: Union[None, List[str], List[os.PathLike[str]], List[_Path]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ...
|
||||
def find_module(name: str, path: Union[None, List[str], List[os.PathLike[str]], List[StrPath]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ...
|
||||
else:
|
||||
def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ...
|
||||
def reload(module: types.ModuleType) -> types.ModuleType: ...
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import io
|
||||
import sys
|
||||
from os.path import _PathType
|
||||
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
from _typeshed import AnyPath
|
||||
from typing_extensions import Literal
|
||||
|
||||
_OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||
_OpenTextWritingMode = Literal["wt", "xt", "at"]
|
||||
|
||||
_PathOrFile = Union[_PathType, IO[bytes]]
|
||||
_PathOrFile = Union[AnyPath, IO[bytes]]
|
||||
|
||||
_FilterChain = Sequence[Mapping[str, Any]]
|
||||
_T = TypeVar("_T")
|
||||
@@ -125,7 +120,7 @@ def open(
|
||||
) -> LZMAFile: ...
|
||||
@overload
|
||||
def open(
|
||||
filename: _PathType,
|
||||
filename: AnyPath,
|
||||
mode: Literal["rt"],
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
@@ -138,7 +133,7 @@ def open(
|
||||
) -> TextIO: ...
|
||||
@overload
|
||||
def open(
|
||||
filename: _PathType,
|
||||
filename: AnyPath,
|
||||
mode: _OpenTextWritingMode,
|
||||
*,
|
||||
format: Optional[int] = ...,
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
# Stubs for os
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
from io import TextIOWrapper as _TextIOWrapper
|
||||
from posix import listdir as listdir, times_result
|
||||
import sys
|
||||
from typing import (
|
||||
Mapping, MutableMapping, Dict, List, Any, Tuple, Iterable, Iterator, NoReturn, overload, Union, AnyStr,
|
||||
Optional, Generic, Set, Callable, Text, Sequence, NamedTuple, TypeVar, ContextManager
|
||||
Optional, Generic, Set, Callable, Text, Sequence, NamedTuple, ContextManager, TypeVar
|
||||
)
|
||||
from _typeshed import AnyPath
|
||||
|
||||
# Re-exported names from other modules.
|
||||
from builtins import OSError as error
|
||||
from . import path as path
|
||||
|
||||
_T = TypeVar('_T')
|
||||
# We need to use something from path, or flake8 and pytype get unhappy
|
||||
_supports_unicode_filenames = path.supports_unicode_filenames
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
# ----- os variables -----
|
||||
|
||||
@@ -244,8 +245,7 @@ class stat_result:
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike as PathLike # See comment in builtins
|
||||
|
||||
_PathType = path._PathType
|
||||
_FdOrPathType = Union[int, _PathType]
|
||||
_FdOrAnyPath = Union[int, AnyPath]
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
class DirEntry(PathLike[AnyStr]):
|
||||
@@ -393,7 +393,7 @@ else:
|
||||
def fstat(fd: int) -> stat_result: ...
|
||||
def fsync(fd: int) -> None: ...
|
||||
def lseek(__fd: int, __position: int, __how: int) -> int: ...
|
||||
def open(path: _PathType, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ...
|
||||
def open(path: AnyPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ...
|
||||
def pipe() -> Tuple[int, int]: ...
|
||||
def read(__fd: int, __length: int) -> bytes: ...
|
||||
|
||||
@@ -440,59 +440,59 @@ if sys.platform != 'win32':
|
||||
def ttyname(__fd: int) -> str: ...
|
||||
def write(__fd: int, __data: bytes) -> int: ...
|
||||
def access(
|
||||
path: _FdOrPathType,
|
||||
path: _FdOrAnyPath,
|
||||
mode: int,
|
||||
*,
|
||||
dir_fd: Optional[int] = ...,
|
||||
effective_ids: bool = ...,
|
||||
follow_symlinks: bool = ...,
|
||||
) -> bool: ...
|
||||
def chdir(path: _FdOrPathType) -> None: ...
|
||||
def chdir(path: _FdOrAnyPath) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
def fchdir(fd: int) -> None: ...
|
||||
def getcwd() -> str: ...
|
||||
def getcwdb() -> bytes: ...
|
||||
def chmod(path: _FdOrPathType, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ...
|
||||
def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
def chflags(path: _PathType, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix
|
||||
def chown(path: _FdOrPathType, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... # Unix only
|
||||
def chflags(path: AnyPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix
|
||||
def chown(path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... # Unix only
|
||||
if sys.platform != 'win32':
|
||||
# Unix only
|
||||
def chroot(path: _PathType) -> None: ...
|
||||
def lchflags(path: _PathType, flags: int) -> None: ...
|
||||
def lchmod(path: _PathType, mode: int) -> None: ...
|
||||
def lchown(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def chroot(path: AnyPath) -> None: ...
|
||||
def lchflags(path: AnyPath, flags: int) -> None: ...
|
||||
def lchmod(path: AnyPath, mode: int) -> None: ...
|
||||
def lchown(path: AnyPath, uid: int, gid: int) -> None: ...
|
||||
def link(
|
||||
src: _PathType,
|
||||
dst: _PathType,
|
||||
src: AnyPath,
|
||||
dst: AnyPath,
|
||||
*,
|
||||
src_dir_fd: Optional[int] = ...,
|
||||
dst_dir_fd: Optional[int] = ...,
|
||||
follow_symlinks: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
def lstat(path: _PathType, *, dir_fd: Optional[int] = ...) -> stat_result: ...
|
||||
def mkdir(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def lstat(path: AnyPath, *, dir_fd: Optional[int] = ...) -> stat_result: ...
|
||||
def mkdir(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
def mkfifo(path: _PathType, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only
|
||||
def makedirs(name: _PathType, mode: int = ..., exist_ok: bool = ...) -> None: ...
|
||||
def mkfifo(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only
|
||||
def makedirs(name: AnyPath, mode: int = ..., exist_ok: bool = ...) -> None: ...
|
||||
if sys.platform != "win32":
|
||||
def mknod(path: _PathType, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def mknod(path: AnyPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def major(__device: int) -> int: ...
|
||||
def minor(__device: int) -> int: ...
|
||||
def makedev(__major: int, __minor: int) -> int: ...
|
||||
def pathconf(path: _FdOrPathType, name: Union[str, int]) -> int: ... # Unix only
|
||||
def pathconf(path: _FdOrAnyPath, name: Union[str, int]) -> int: ... # Unix only
|
||||
if sys.version_info >= (3, 6):
|
||||
def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ...
|
||||
else:
|
||||
def readlink(path: AnyStr, *, dir_fd: Optional[int] = ...) -> AnyStr: ...
|
||||
def remove(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def removedirs(name: _PathType) -> None: ...
|
||||
def rename(src: _PathType, dst: _PathType, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
|
||||
def renames(old: _PathType, new: _PathType) -> None: ...
|
||||
def replace(src: _PathType, dst: _PathType, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
|
||||
def rmdir(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def removedirs(name: AnyPath) -> None: ...
|
||||
def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
|
||||
def renames(old: AnyPath, new: AnyPath) -> None: ...
|
||||
def replace(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
|
||||
def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]):
|
||||
def __next__(self) -> DirEntry[AnyStr]: ...
|
||||
@@ -516,27 +516,27 @@ else:
|
||||
def scandir(path: None = ...) -> Iterator[DirEntry[str]]: ...
|
||||
@overload
|
||||
def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ...
|
||||
def stat(path: _FdOrPathType, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
if sys.version_info < (3, 7):
|
||||
@overload
|
||||
def stat_float_times() -> bool: ...
|
||||
@overload
|
||||
def stat_float_times(__newvalue: bool) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
def statvfs(path: _FdOrPathType) -> statvfs_result: ... # Unix only
|
||||
def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only
|
||||
def symlink(
|
||||
src: _PathType,
|
||||
dst: _PathType,
|
||||
src: AnyPath,
|
||||
dst: AnyPath,
|
||||
target_is_directory: bool = ...,
|
||||
*,
|
||||
dir_fd: Optional[int] = ...,
|
||||
) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
def sync() -> None: ... # Unix only
|
||||
def truncate(path: _FdOrPathType, length: int) -> None: ... # Unix only up to version 3.4
|
||||
def unlink(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to version 3.4
|
||||
def unlink(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
def utime(
|
||||
path: _FdOrPathType,
|
||||
path: _FdOrAnyPath,
|
||||
times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ...,
|
||||
*,
|
||||
ns: Tuple[int, int] = ...,
|
||||
@@ -574,29 +574,29 @@ if sys.platform != 'win32':
|
||||
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
if sys.platform == "linux":
|
||||
def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ...
|
||||
def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ...
|
||||
def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ...
|
||||
def setxattr(path: _FdOrPathType, attribute: _PathType, value: bytes, flags: int = ..., *,
|
||||
def getxattr(path: _FdOrAnyPath, attribute: AnyPath, *, follow_symlinks: bool = ...) -> bytes: ...
|
||||
def listxattr(path: _FdOrAnyPath, *, follow_symlinks: bool = ...) -> List[str]: ...
|
||||
def removexattr(path: _FdOrAnyPath, attribute: AnyPath, *, follow_symlinks: bool = ...) -> None: ...
|
||||
def setxattr(path: _FdOrAnyPath, attribute: AnyPath, value: bytes, flags: int = ..., *,
|
||||
follow_symlinks: bool = ...) -> None: ...
|
||||
|
||||
def abort() -> NoReturn: ...
|
||||
# These are defined as execl(file, *args) but the first *arg is mandatory.
|
||||
def execl(file: _PathType, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ...
|
||||
def execlp(file: _PathType, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ...
|
||||
def execl(file: AnyPath, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ...
|
||||
def execlp(file: AnyPath, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ...
|
||||
|
||||
# These are: execle(file, *args, env) but env is pulled from the last element of the args.
|
||||
def execle(file: _PathType, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
def execlpe(file: _PathType, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
def execle(file: AnyPath, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
def execlpe(file: AnyPath, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
|
||||
# The docs say `args: tuple or list of strings`
|
||||
# The implementation enforces tuple or list so we can't use Sequence.
|
||||
_ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]]
|
||||
_ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]]
|
||||
def execv(__path: _PathType, __argv: _ExecVArgs) -> NoReturn: ...
|
||||
def execve(path: _FdOrPathType, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ...
|
||||
def execvp(file: _PathType, args: _ExecVArgs) -> NoReturn: ...
|
||||
def execvpe(file: _PathType, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ...
|
||||
def execv(__path: AnyPath, __argv: _ExecVArgs) -> NoReturn: ...
|
||||
def execve(path: _FdOrAnyPath, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ...
|
||||
def execvp(file: AnyPath, args: _ExecVArgs) -> NoReturn: ...
|
||||
def execvpe(file: AnyPath, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ...
|
||||
|
||||
def _exit(status: int) -> NoReturn: ...
|
||||
def kill(__pid: int, __signal: int) -> None: ...
|
||||
@@ -613,29 +613,29 @@ class _wrap_close(_TextIOWrapper):
|
||||
def close(self) -> Optional[int]: ... # type: ignore
|
||||
def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ...
|
||||
|
||||
def spawnl(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnle(mode: int, file: _PathType, arg0: Union[bytes, Text],
|
||||
def spawnl(mode: int, file: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnle(mode: int, file: AnyPath, arg0: Union[bytes, Text],
|
||||
*args: Any) -> int: ... # Imprecise sig
|
||||
if sys.platform != "win32":
|
||||
def spawnv(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnve(mode: int, file: _PathType, args: List[Union[bytes, Text]],
|
||||
def spawnv(mode: int, file: AnyPath, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnve(mode: int, file: AnyPath, args: List[Union[bytes, Text]],
|
||||
env: _ExecEnv) -> int: ...
|
||||
else:
|
||||
def spawnv(__mode: int, __path: _PathType, __argv: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnve(__mode: int, __path: _PathType, __argv: List[Union[bytes, Text]],
|
||||
def spawnv(__mode: int, __path: AnyPath, __argv: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnve(__mode: int, __path: AnyPath, __argv: List[Union[bytes, Text]],
|
||||
__env: _ExecEnv) -> int: ...
|
||||
def system(command: _PathType) -> int: ...
|
||||
def system(command: AnyPath) -> int: ...
|
||||
def times() -> times_result: ...
|
||||
def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ...
|
||||
|
||||
if sys.platform == 'win32':
|
||||
def startfile(path: _PathType, operation: Optional[str] = ...) -> None: ...
|
||||
def startfile(path: AnyPath, operation: Optional[str] = ...) -> None: ...
|
||||
else:
|
||||
# Unix only
|
||||
def spawnlp(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnlpe(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature
|
||||
def spawnvp(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnvpe(mode: int, file: _PathType, args: List[Union[bytes, Text]], env: _ExecEnv) -> int: ...
|
||||
def spawnlp(mode: int, file: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnlpe(mode: int, file: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature
|
||||
def spawnvp(mode: int, file: AnyPath, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnvpe(mode: int, file: AnyPath, args: List[Union[bytes, Text]], env: _ExecEnv) -> int: ...
|
||||
def wait() -> Tuple[int, int]: ... # Unix only
|
||||
from posix import waitid_result
|
||||
def waitid(idtype: int, ident: int, options: int) -> waitid_result: ...
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
|
||||
# Stubs for os.path
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
|
||||
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Text, Callable, Optional
|
||||
from genericpath import exists as exists
|
||||
from _typeshed import StrPath, BytesPath, AnyPath
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike
|
||||
_PathType = Union[bytes, Text, _PathLike]
|
||||
_StrPath = Union[Text, _PathLike[Text]]
|
||||
_BytesPath = Union[bytes, _PathLike[bytes]]
|
||||
else:
|
||||
_PathType = Union[bytes, Text]
|
||||
_StrPath = Text
|
||||
_BytesPath = bytes
|
||||
|
||||
# ----- os.path variables -----
|
||||
supports_unicode_filenames: bool
|
||||
@@ -90,31 +81,31 @@ else:
|
||||
def realpath(filename: AnyStr) -> AnyStr: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
# In reality it returns str for sequences of _StrPath and bytes for sequences
|
||||
# of _BytesPath, but mypy does not accept such a signature.
|
||||
def commonpath(paths: Sequence[_PathType]) -> Any: ...
|
||||
# In reality it returns str for sequences of StrPath and bytes for sequences
|
||||
# of BytesPath, but mypy does not accept such a signature.
|
||||
def commonpath(paths: Sequence[AnyPath]) -> Any: ...
|
||||
elif sys.version_info >= (3, 5):
|
||||
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
|
||||
|
||||
# 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[_PathType]) -> Any: ...
|
||||
def commonprefix(m: Sequence[AnyPath]) -> Any: ...
|
||||
|
||||
def lexists(path: _PathType) -> bool: ...
|
||||
def lexists(path: AnyPath) -> bool: ...
|
||||
|
||||
# These return float if os.stat_float_times() == True,
|
||||
# but int is a subclass of float.
|
||||
def getatime(filename: _PathType) -> float: ...
|
||||
def getmtime(filename: _PathType) -> float: ...
|
||||
def getctime(filename: _PathType) -> float: ...
|
||||
def getatime(filename: AnyPath) -> float: ...
|
||||
def getmtime(filename: AnyPath) -> float: ...
|
||||
def getctime(filename: AnyPath) -> float: ...
|
||||
|
||||
def getsize(filename: _PathType) -> int: ...
|
||||
def isabs(s: _PathType) -> bool: ...
|
||||
def isfile(path: _PathType) -> bool: ...
|
||||
def isdir(s: _PathType) -> bool: ...
|
||||
def islink(path: _PathType) -> bool: ...
|
||||
def ismount(path: _PathType) -> bool: ...
|
||||
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: ...
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
|
||||
@@ -124,28 +115,27 @@ if sys.version_info < (3, 0):
|
||||
@overload
|
||||
def join(__p1: bytes, *p: bytes) -> bytes: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
|
||||
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
|
||||
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
|
||||
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: Text, *p: _PathType) -> Text: ...
|
||||
def join(__p1: Text, *p: AnyPath) -> Text: ...
|
||||
elif sys.version_info >= (3, 6):
|
||||
# Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway.
|
||||
@overload
|
||||
def join(a: _StrPath, *paths: _StrPath) -> Text: ...
|
||||
def join(a: StrPath, *paths: StrPath) -> Text: ...
|
||||
@overload
|
||||
def join(a: _BytesPath, *paths: _BytesPath) -> bytes: ...
|
||||
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
|
||||
else:
|
||||
def join(a: AnyStr, *paths: AnyStr) -> AnyStr: ...
|
||||
|
||||
@overload
|
||||
def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ...
|
||||
def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
|
||||
@overload
|
||||
def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ...
|
||||
def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
|
||||
|
||||
def samefile(f1: _PathType, f2: _PathType) -> bool: ...
|
||||
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
|
||||
def sameopenfile(fp1: int, fp2: int) -> bool: ...
|
||||
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...
|
||||
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import sys
|
||||
|
||||
from typing import Optional, Sequence, Text, Union, AnyStr
|
||||
from _typeshed import AnyPath
|
||||
from typing import Optional, Sequence, Text
|
||||
from types import SimpleNamespace
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike
|
||||
_Path = Union[str, bytes, _PathLike[str], _PathLike[bytes]]
|
||||
else:
|
||||
_Path = Union[str, bytes]
|
||||
|
||||
class EnvBuilder:
|
||||
system_site_packages: bool
|
||||
clear: bool
|
||||
@@ -24,11 +18,11 @@ class EnvBuilder:
|
||||
def __init__(self, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., upgrade: bool = ..., with_pip: bool = ...) -> None: ...
|
||||
def create(self, env_dir: _Path) -> None: ...
|
||||
def clear_directory(self, path: _Path) -> None: ... # undocumented
|
||||
def ensure_directories(self, env_dir: _Path) -> SimpleNamespace: ...
|
||||
def create(self, env_dir: AnyPath) -> None: ...
|
||||
def clear_directory(self, path: AnyPath) -> None: ... # undocumented
|
||||
def ensure_directories(self, env_dir: AnyPath) -> SimpleNamespace: ...
|
||||
def create_configuration(self, context: SimpleNamespace) -> None: ...
|
||||
def symlink_or_copy(self, src: _Path, dst: _Path, relative_symlinks_ok: bool = ...) -> None: ... # undocumented
|
||||
def symlink_or_copy(self, src: AnyPath, dst: AnyPath, relative_symlinks_ok: bool = ...) -> None: ... # undocumented
|
||||
def setup_python(self, context: SimpleNamespace) -> None: ...
|
||||
def _setup_pip(self, context: SimpleNamespace) -> None: ... # undocumented
|
||||
def setup_scripts(self, context: SimpleNamespace) -> None: ...
|
||||
@@ -39,10 +33,10 @@ class EnvBuilder:
|
||||
def upgrade_dependencies(self, context: SimpleNamespace) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ..., upgrade_deps: bool = ...) -> None: ...
|
||||
def create(env_dir: AnyPath, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ..., upgrade_deps: bool = ...) -> None: ...
|
||||
elif sys.version_info >= (3, 6):
|
||||
def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ...) -> None: ...
|
||||
def create(env_dir: AnyPath, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ..., prompt: Optional[str] = ...) -> None: ...
|
||||
else:
|
||||
def create(env_dir: _Path, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ...) -> None: ...
|
||||
def create(env_dir: AnyPath, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., with_pip: bool = ...) -> None: ...
|
||||
|
||||
def main(args: Optional[Sequence[Text]] = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user