From 4ce35091ebad3a0a83911e6476ae6a52f1e2cb57 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Thu, 2 Sep 2021 22:24:50 -0600 Subject: [PATCH] Document the black shim a touch --- tools/black/__main__.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/black/__main__.py b/tools/black/__main__.py index c4a3e54..cff5a1c 100644 --- a/tools/black/__main__.py +++ b/tools/black/__main__.py @@ -1,10 +1,9 @@ -"""A shim to black which knows how to tee output.""" +"""A shim to black which knows how to tee output for --output-file.""" import argparse -from contextlib import contextmanager import sys -from black import patched_main +from black import patched_main, nullcontext parser = argparse.ArgumentParser() @@ -12,7 +11,7 @@ parser.add_argument("--output-file", default=None) class Tee(object): - """Tee all I/O to a file and stdout.""" + """Something that looks like a File/Writeable but does teed writes.""" def __init__(self, name, mode): self._file = open(name, mode) @@ -38,11 +37,6 @@ class Tee(object): self._file.close() -@contextmanager -def nullctx(): - yield - - if __name__ == "__main__": opts, args = parser.parse_known_args() @@ -50,7 +44,7 @@ if __name__ == "__main__": print("Teeig output....") ctx = Tee(opts.output_file, "w") else: - ctx = nullctx() + ctx = nullcontext() with ctx: sys.argv = [sys.argv[0]] + args