From d8188211216f909cb6b4d4741386478fd69f9b48 Mon Sep 17 00:00:00 2001 From: Rahix Date: Tue, 5 May 2020 14:01:24 +0200 Subject: [PATCH] atomicwrites: Allow any PathLike for paths (#3965) As of version 1.4.0, from PR untitaker/python-atomicwrites#48, atomicwrites allows any PathLike object for its path args. --- third_party/2and3/atomicwrites/__init__.pyi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/atomicwrites/__init__.pyi b/third_party/2and3/atomicwrites/__init__.pyi index cecbd10bc..0a11eda45 100644 --- a/third_party/2and3/atomicwrites/__init__.pyi +++ b/third_party/2and3/atomicwrites/__init__.pyi @@ -1,15 +1,22 @@ +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] + def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... class AtomicWriter(object): - def __init__(self, path: Union[Text, bytes], mode: Text = ..., overwrite: bool = ...) -> None: ... + def __init__(self, path: _Path, 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: Union[None, Text, bytes] = ..., **kwargs: Any) -> IO[Any]: ... + def get_fileobject(self, dir: Optional[_Path] = ..., **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: Union[Text, bytes], writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object, + path: _Path, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object, ) -> ContextManager[IO[Any]]: ...