X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/475179a53af1948ca726de1b11d4cdbe2aa90e58..7e1c5b2ba6355f1a6916cf5545dc577cf2e6c727:/black.py diff --git a/black.py b/black.py index f03c4f1..53d332a 100644 --- a/black.py +++ b/black.py @@ -320,6 +320,15 @@ class DebugVisitor(Visitor[T]): out(f' {node.prefix!r}', fg='green', bold=False, nl=False) out(f' {node.value!r}', fg='blue', bold=False) + @classmethod + def show(cls, code: str) -> None: + """Pretty-prints a given string of `code`. + + Convenience method for debugging. + """ + v: DebugVisitor[None] = DebugVisitor() + list(v.visit(lib2to3_parse(code))) + KEYWORDS = set(keyword.kwlist) WHITESPACE = {token.DEDENT, token.INDENT, token.NEWLINE}