forked from python/typeshed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to ContextManager (python#1249)
* add typing.ContextManager for 3.6+ only This fixes the easier part of python#655. Would it make sense to add a generic typing.ContextManager that exists in any Python version? * update comment * fix argument types for ContextManager.__exit__ * add AsyncContextManager * add @asynccontextmanager * typing.ContextManager now always exists * back out async-related changes Will submit those in a separate PR later * fix import order * AbstractContextManager only exists in 3.6+ * AbstractContextManager -> ContextManager
- Loading branch information
1 parent
aff86f8
commit 589f624
Showing
5 changed files
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import contextlib | ||
import os | ||
import sys | ||
import tempfile | ||
from typing import Any, AnyStr, Callable, IO, Iterator, Text | ||
from typing import Any, AnyStr, Callable, ContextManager, IO, Iterator, Text | ||
|
||
def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... | ||
def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... | ||
class AtomicWriter(object): | ||
def __init__(self, path: AnyStr, mode: Text='w', overwrite: bool=False) -> None: ... | ||
def open(self) -> contextlib.ContextManager[IO]: ... | ||
def _open(self, get_fileobject: Callable) -> contextlib.ContextManager[IO]: ... | ||
def open(self) -> ContextManager[IO]: ... | ||
def _open(self, get_fileobject: Callable) -> ContextManager[IO]: ... | ||
def get_fileobject(self, dir: AnyStr=None, **kwargs) -> IO: ... | ||
def sync(self, f: IO) -> None: ... | ||
def commit(self, f: IO) -> None: ... | ||
def rollback(self, f: IO) -> None: ... | ||
def atomic_write(path: AnyStr, writer_cls: type=AtomicWriter, **cls_kwargs) -> contextlib.ContextManager[IO]: ... | ||
def atomic_write(path: AnyStr, writer_cls: type=AtomicWriter, **cls_kwargs) -> ContextManager[IO]: ... |