This file contains hidden or 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
| from contextlib import contextmanager | |
| from os import rename | |
| from tempfile import NamedTemporaryFile | |
| from typing import BinaryIO | |
| @contextmanager | |
| def atomic_write(path: str, mode: str = 'w', encoding: str = 'utf-8') -> BinaryIO: | |
| temp_file = NamedTemporaryFile(mode=mode, encoding=encoding, delete=False) | |
| try: |