From 82198030eef6f99ad47470d82c34d9a6e1a4e6df Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Mon, 23 Apr 2018 14:24:14 -0700 Subject: [PATCH] Remove nonsensical grammar from blib2to3 --- black.py | 1 - blib2to3/pygram.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) 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"] -- 2.39.5