]>
git.madduck.net Git - etc/vim.git/blobdiff - black.py
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
else:
cache: Cache = {}
if write_back != WriteBack.DIFF:
else:
cache: Cache = {}
if write_back != WriteBack.DIFF:
+ cache = read_cache(line_length )
src = src.resolve()
if src in cache and cache[src] == get_cache_info(src):
changed = Changed.CACHED
src = src.resolve()
if src in cache and cache[src] == get_cache_info(src):
changed = Changed.CACHED
):
changed = Changed.YES
if write_back != WriteBack.DIFF and changed is not Changed.NO:
):
changed = Changed.YES
if write_back != WriteBack.DIFF and changed is not Changed.NO:
- write_cache(cache, [src])
+ write_cache(cache, [src], line_length )
report.done(src, changed)
except Exception as exc:
report.failed(src, str(exc))
report.done(src, changed)
except Exception as exc:
report.failed(src, str(exc))
"""
cache: Cache = {}
if write_back != WriteBack.DIFF:
"""
cache: Cache = {}
if write_back != WriteBack.DIFF:
+ cache = read_cache(line_length )
sources, cached = filter_cached(cache, sources)
for src in cached:
report.done(src, Changed.CACHED)
sources, cached = filter_cached(cache, sources)
for src in cached:
report.done(src, Changed.CACHED)
if cancelled:
await asyncio.gather(*cancelled, loop=loop, return_exceptions=True)
if write_back != WriteBack.DIFF and formatted:
if cancelled:
await asyncio.gather(*cancelled, loop=loop, return_exceptions=True)
if write_back != WriteBack.DIFF and formatted:
- write_cache(cache, formatted)
+ write_cache(cache, formatted, line_length )
def format_file_in_place(
def format_file_in_place(
CACHE_DIR = Path(user_cache_dir("black", version=__version__))
CACHE_DIR = Path(user_cache_dir("black", version=__version__))
-CACHE_FILE = CACHE_DIR / "cache.pickle"
-def read_cache() -> Cache:
+def get_cache_file(line_length: int) -> Path:
+ return CACHE_DIR / f"cache.{line_length}.pickle"
+
+
+def read_cache(line_length: int) -> Cache:
"""Read the cache if it exists and is well formed.
If it is not well formed, the call to write_cache later should resolve the issue.
"""
"""Read the cache if it exists and is well formed.
If it is not well formed, the call to write_cache later should resolve the issue.
"""
- if not CACHE_FILE.exists():
+ cache_file = get_cache_file(line_length)
+ if not cache_file.exists():
- with CACHE_FILE .open("rb") as fobj:
+ with cache_file .open("rb") as fobj:
try:
cache: Cache = pickle.load(fobj)
except pickle.UnpicklingError:
try:
cache: Cache = pickle.load(fobj)
except pickle.UnpicklingError:
-def write_cache(cache: Cache, sources: List[Path]) -> None:
+def write_cache(cache: Cache, sources: List[Path], line_length: int ) -> None:
"""Update the cache file."""
"""Update the cache file."""
+ cache_file = get_cache_file(line_length)
try:
if not CACHE_DIR.exists():
CACHE_DIR.mkdir(parents=True)
new_cache = {**cache, **{src.resolve(): get_cache_info(src) for src in sources}}
try:
if not CACHE_DIR.exists():
CACHE_DIR.mkdir(parents=True)
new_cache = {**cache, **{src.resolve(): get_cache_info(src) for src in sources}}
- with CACHE_FILE .open("wb") as fobj:
+ with cache_file .open("wb") as fobj:
pickle.dump(new_cache, fobj, protocol=pickle.HIGHEST_PROTOCOL)
except OSError:
pass
pickle.dump(new_cache, fobj, protocol=pickle.HIGHEST_PROTOCOL)
except OSError:
pass