From b85fd64a828f8c4c9f37294274d296ad67c4ed57 Mon Sep 17 00:00:00 2001 From: Aleck Landgraf Date: Thu, 2 Jun 2016 15:02:22 -0700 Subject: [PATCH 1/2] Fixes #293 showing an errant space in the docs with the ``hang-closing`` flag. --- docs/intro.rst | 4 ++-- testsuite/E12.py | 8 ++++++++ testsuite/support.py | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index 12f67d7e..d474c864 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -405,8 +405,8 @@ This is the current list of error and warning codes: **(*)** In the default configuration, the checks **E121**, **E123**, **E126**, **E133**, **E226**, **E241**, **E242**, **E704** and **W503** are ignored because they are not rules unanimously accepted, and `PEP 8`_ does not enforce them. The -check **E133** is mutually exclusive with check **E123**. Use switch ``--hang- -closing`` to report **E133** instead of **E123**. +check **E133** is mutually exclusive with check **E123**. Use switch +``--hang-closing`` to report **E133** instead of **E123**. **(^)** These checks can be disabled at the line level using the ``# noqa`` special comment. This possibility should be reserved for special cases. diff --git a/testsuite/E12.py b/testsuite/E12.py index a995c955..746ea0c9 100644 --- a/testsuite/E12.py +++ b/testsuite/E12.py @@ -373,4 +373,12 @@ def example_issue254(): print(a , end=' ') +#: E133:3:1 --hang-closing +a = [ + 12 +] +#: Okay --hang-closing +a = [ + 12 + ] #: diff --git a/testsuite/support.py b/testsuite/support.py index 003f181b..4469996a 100644 --- a/testsuite/support.py +++ b/testsuite/support.py @@ -146,6 +146,19 @@ def init_tests(pep8style): report = pep8style.init_report(TestReport) runner = pep8style.input_file + def set_hang_closing_option(pep8style, codes): + """Set hang-closing option if present in the test codes. + + (mutates pep8style) + + Usage in test: + #: #E133:3:1 --with-hanging + + """ + pep8style.options.hang_closing = '--hang-closing' in codes + codes = [c for c in codes if c != '--hang-closing'] + return codes + def run_tests(filename): """Run all the tests from a file.""" lines = readlines(filename) + ['#:\n'] @@ -162,6 +175,9 @@ def run_tests(filename): if codes and index: if 'noeol' in codes: testcase[-1] = testcase[-1].rstrip('\n') + + codes = set_hang_closing_option(pep8style, codes) + codes = [c for c in codes if c not in ('Okay', 'noeol')] # Run the checker From f2a1e26b2d1e72cb9471fc6f8e270f56a0c6f548 Mon Sep 17 00:00:00 2001 From: Aleck Landgraf Date: Fri, 3 Jun 2016 10:06:05 -0700 Subject: [PATCH 2/2] fixes typo --- testsuite/support.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testsuite/support.py b/testsuite/support.py index 4469996a..2b1f7a01 100644 --- a/testsuite/support.py +++ b/testsuite/support.py @@ -152,7 +152,9 @@ def set_hang_closing_option(pep8style, codes): (mutates pep8style) Usage in test: - #: #E133:3:1 --with-hanging + #: E133:3:1 --hang-closing + or + #: Okay --hang-closing """ pep8style.options.hang_closing = '--hang-closing' in codes