mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-03-25 17:32:23 +10:00
add proper typechecked json parsing and dumping
This commit is contained in:
@@ -675,8 +675,8 @@ class ExtendedEncoder(JSONEncoder):
|
||||
return JSONEncoder.default(self, obj)
|
||||
|
||||
|
||||
def atomic_write(contents: Union[dict, str], path: str):
|
||||
"""Safe atomic file write and swap using a tmp file"""
|
||||
def atomic_write(contents: Union[dict, str], path: str) -> None:
|
||||
"""Safe atomic write to filesystem by writing to temp file + atomic rename"""
|
||||
try:
|
||||
tmp_file = '{}.tmp'.format(path)
|
||||
with open(tmp_file, 'w+', encoding='utf-8') as f:
|
||||
|
||||
Reference in New Issue
Block a user