From: Ɓukasz Langa Date: Mon, 23 Apr 2018 21:24:14 +0000 (-0700) Subject: Remove nonsensical grammar from blib2to3 X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/82198030eef6f99ad47470d82c34d9a6e1a4e6df?ds=sidebyside;hp=959ff798bcc908264b7e097df047d7bd42f027a0 Remove nonsensical grammar from blib2to3 --- diff --git a/black.py b/black.py index eafc9e7..da645a1 100644 --- a/black.py +++ b/black.py @@ -428,7 +428,6 @@ def format_str(src_contents: str, line_length: int) -> FileContent: GRAMMARS = [ pygram.python_grammar_no_print_statement_no_exec_statement, pygram.python_grammar_no_print_statement, - pygram.python_grammar_no_exec_statement, pygram.python_grammar, ] diff --git a/blib2to3/pygram.py b/blib2to3/pygram.py index bf55ab4..b847c1e 100644 --- a/blib2to3/pygram.py +++ b/blib2to3/pygram.py @@ -29,16 +29,16 @@ class Symbols(object): setattr(self, name, symbol) +# Python 2 python_grammar = driver.load_packaged_grammar("blib2to3", _GRAMMAR_FILE) python_symbols = Symbols(python_grammar) +# Python 2 + from __future__ import print_function python_grammar_no_print_statement = python_grammar.copy() del python_grammar_no_print_statement.keywords["print"] -python_grammar_no_exec_statement = python_grammar.copy() -del python_grammar_no_exec_statement.keywords["exec"] - +# Python 3 python_grammar_no_print_statement_no_exec_statement = python_grammar.copy() del python_grammar_no_print_statement_no_exec_statement.keywords["print"] del python_grammar_no_print_statement_no_exec_statement.keywords["exec"]