Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions testsuite/E12.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,12 @@ def example_issue254():

print(a
, end=' ')
#: E133:3:1 --hang-closing
a = [
12
]
#: Okay --hang-closing
a = [
12
]
#:
16 changes: 16 additions & 0 deletions testsuite/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, the usage in test would be:

#: E133:3:1 --with-hanging

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading it over, I got the command line arg wrong too, I'll update this, should be --hang-closing not --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']
Expand All @@ -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
Expand Down