mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 06:36:54 +08:00
Add a _typeshed.pyi file and a PathLike alias (#4161)
This commit is contained in:
13
third_party/2and3/atomicwrites/__init__.pyi
vendored
13
third_party/2and3/atomicwrites/__init__.pyi
vendored
@@ -1,22 +1,17 @@
|
||||
import sys
|
||||
from typing import Any, AnyStr, Callable, ContextManager, Generic, IO, Optional, Text, Type, Union
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from os import PathLike
|
||||
_Path = Union[str, bytes, PathLike[str], PathLike[bytes]]
|
||||
else:
|
||||
_Path = Union[Text, bytes]
|
||||
from _typeshed import AnyPath
|
||||
|
||||
def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ...
|
||||
def move_atomic(src: AnyStr, dst: AnyStr) -> None: ...
|
||||
class AtomicWriter(object):
|
||||
def __init__(self, path: _Path, mode: Text = ..., overwrite: bool = ...) -> None: ...
|
||||
def __init__(self, path: AnyPath, mode: Text = ..., overwrite: bool = ...) -> None: ...
|
||||
def open(self) -> ContextManager[IO[Any]]: ...
|
||||
def _open(self, get_fileobject: Callable[..., IO[AnyStr]]) -> ContextManager[IO[AnyStr]]: ...
|
||||
def get_fileobject(self, dir: Optional[_Path] = ..., **kwargs: Any) -> IO[Any]: ...
|
||||
def get_fileobject(self, dir: Optional[AnyPath] = ..., **kwargs: Any) -> IO[Any]: ...
|
||||
def sync(self, f: IO[Any]) -> None: ...
|
||||
def commit(self, f: IO[Any]) -> None: ...
|
||||
def rollback(self, f: IO[Any]) -> None: ...
|
||||
def atomic_write(
|
||||
path: _Path, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object,
|
||||
path: AnyPath, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object,
|
||||
) -> ContextManager[IO[Any]]: ...
|
||||
|
||||
9
third_party/2and3/jinja2/utils.pyi
vendored
9
third_party/2and3/jinja2/utils.pyi
vendored
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Callable, IO, Iterable, Optional, Protocol, Text, TypeVar, Union
|
||||
from _typeshed import AnyPath
|
||||
|
||||
from markupsafe import Markup as Markup, escape as escape, soft_unicode as soft_unicode
|
||||
|
||||
@@ -13,12 +14,6 @@ if sys.version_info >= (3, 8):
|
||||
else:
|
||||
_True = bool
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike
|
||||
_PathType = Union[bytes, Text, _PathLike]
|
||||
else:
|
||||
_PathType = Union[bytes, Text]
|
||||
|
||||
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
|
||||
|
||||
class _ContextFunction(Protocol[_CallableT]):
|
||||
@@ -42,7 +37,7 @@ def select_autoescape(enabled_extensions: Iterable[str] = ..., disabled_extensio
|
||||
def consume(iterable: Iterable[object]) -> None: ...
|
||||
def clear_caches() -> None: ...
|
||||
def import_string(import_name: str, silent: bool = ...) -> Any: ...
|
||||
def open_if_exists(filename: _PathType, mode: str = ...) -> Optional[IO[Any]]: ...
|
||||
def open_if_exists(filename: AnyPath, mode: str = ...) -> Optional[IO[Any]]: ...
|
||||
def object_type_repr(obj: object) -> str: ...
|
||||
def pformat(obj: object, verbose: bool = ...) -> str: ...
|
||||
def urlize(text: Union[Markup, Text], trim_url_limit: Optional[int] = ..., rel: Optional[Union[Markup, Text]] = ..., target: Optional[Union[Markup, Text]] = ...) -> str: ...
|
||||
|
||||
13
third_party/2and3/toml.pyi
vendored
13
third_party/2and3/toml.pyi
vendored
@@ -1,16 +1,15 @@
|
||||
from typing import Any, IO, List, Mapping, MutableMapping, Optional, Protocol, Text, Type, Union
|
||||
from _typeshed import StrPath
|
||||
import datetime
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
if sys.version_info >= (3, 6):
|
||||
_PathLike = StrPath
|
||||
elif sys.version_info >= (3, 4):
|
||||
import pathlib
|
||||
if sys.version_info >= (3, 6):
|
||||
import os
|
||||
_PathLike = Union[Text, pathlib.PurePath, os.PathLike]
|
||||
else:
|
||||
_PathLike = Union[Text, pathlib.PurePath]
|
||||
_PathLike = Union[StrPath, pathlib.PurePath]
|
||||
else:
|
||||
_PathLike = Text
|
||||
_PathLike = StrPath
|
||||
|
||||
class _Writable(Protocol):
|
||||
def write(self, obj: str) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user