Loading black.py +5 −4 Changes for black.py: 5 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import re import signal import sys import tempfile import tokenize from typing import ( Any, Loading Loading @@ -3647,11 +3648,11 @@ def write_cache( """Update the cache file.""" cache_file = get_cache_file(line_length, mode) try: if not CACHE_DIR.exists(): CACHE_DIR.mkdir(parents=True) CACHE_DIR.mkdir(parents=True, exist_ok=True) new_cache = {**cache, **{src.resolve(): get_cache_info(src) for src in sources}} with cache_file.open("wb") as fobj: pickle.dump(new_cache, fobj, protocol=pickle.HIGHEST_PROTOCOL) with tempfile.NamedTemporaryFile(dir=str(cache_file.parent), delete=False) as f: pickle.dump(new_cache, f, protocol=pickle.HIGHEST_PROTOCOL) os.replace(f.name, cache_file) except OSError: pass Loading blib2to3/pgen2/grammar.py +4 −1 Changes for blib2to3/pgen2/grammar.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ """ # Python imports import os.path import pickle import tempfile # Local imports from . import token Loading Loading @@ -86,8 +88,9 @@ def __init__(self): def dump(self, filename): """Dump the grammar tables to a pickle file.""" with open(filename, "wb") as f: with tempfile.NamedTemporaryFile(dir=os.path.dirname(filename), delete=False) as f: pickle.dump(self.__dict__, f, pickle.HIGHEST_PROTOCOL) os.replace(f.name, filename) def load(self, filename): """Load the grammar tables from a pickle file.""" Loading Loading
black.py +5 −4 Changes for black.py: 5 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import re import signal import sys import tempfile import tokenize from typing import ( Any, Loading Loading @@ -3647,11 +3648,11 @@ def write_cache( """Update the cache file.""" cache_file = get_cache_file(line_length, mode) try: if not CACHE_DIR.exists(): CACHE_DIR.mkdir(parents=True) CACHE_DIR.mkdir(parents=True, exist_ok=True) new_cache = {**cache, **{src.resolve(): get_cache_info(src) for src in sources}} with cache_file.open("wb") as fobj: pickle.dump(new_cache, fobj, protocol=pickle.HIGHEST_PROTOCOL) with tempfile.NamedTemporaryFile(dir=str(cache_file.parent), delete=False) as f: pickle.dump(new_cache, f, protocol=pickle.HIGHEST_PROTOCOL) os.replace(f.name, cache_file) except OSError: pass Loading
blib2to3/pgen2/grammar.py +4 −1 Changes for blib2to3/pgen2/grammar.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ """ # Python imports import os.path import pickle import tempfile # Local imports from . import token Loading Loading @@ -86,8 +88,9 @@ def __init__(self): def dump(self, filename): """Dump the grammar tables to a pickle file.""" with open(filename, "wb") as f: with tempfile.NamedTemporaryFile(dir=os.path.dirname(filename), delete=False) as f: pickle.dump(self.__dict__, f, pickle.HIGHEST_PROTOCOL) os.replace(f.name, filename) def load(self, filename): """Load the grammar tables from a pickle file.""" Loading