Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,11 @@ def indentation(logical_line, previous_logical, indent_char,
elif not indent_expect and indent_level > previous_indent_level:
yield 0, tmpl % (3 + c, "unexpected indentation")

expected_indent_level = previous_indent_level + 4
if indent_expect and indent_level > expected_indent_level:
yield 0, tmpl % (7, 'over-indented')
if indent_expect:
expected_indent_amount = 8 if indent_char == '\t' else 4
expected_indent_level = previous_indent_level + expected_indent_amount
if indent_level > expected_indent_level:
yield 0, tmpl % (7, 'over-indented')


@register_check
Expand Down
4 changes: 2 additions & 2 deletions testsuite/E10.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
for b in 'xyz':
print a # indented with 8 spaces
print b # indented with 1 tab
#: E101 E117 E122 W191 W191
#: E101 E122 W191 W191
if True:
pass

Expand All @@ -27,7 +27,7 @@ def tearDown(self):
pass

#
#: E101 E117 W191 W191
#: E101 W191 W191
if True:
foo(1,
2)
Expand Down
3 changes: 3 additions & 0 deletions testsuite/E11.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ def start(self):
#: E117
def start():
print
#: E117 W191
def start():
print
2 changes: 1 addition & 1 deletion testsuite/E90.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
}
#: E901
= [x
#: E901 E101 E117 W191
#: E901 E101 W191
while True:
try:
pass
Expand Down
38 changes: 19 additions & 19 deletions testsuite/W19.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#: E117 W191
#: W191
if False:
print # indented with 1 tab
#:
Expand All @@ -7,56 +7,56 @@
#: W191
y = x == 2 \
or x == 3
#: E101 E117 W191 W504
#: E101 W191 W504
if (
x == (
3
) or
y == 4):
pass
#: E101 E117 W191
#: E101 W191
if x == 2 \
or y > 1 \
or x == 3:
pass
#: E101 E117 W191
#: E101 W191
if x == 2 \
or y > 1 \
or x == 3:
pass
#:

#: E101 E117 W191 W504
#: E101 W191 W504
if (foo == bar and
baz == frop):
pass
#: E101 E117 W191 W504
#: E101 W191 W504
if (
foo == bar and
baz == frop
):
pass
#:

#: E101 E101 E117 W191 W191
#: E101 E101 W191 W191
if start[1] > end_col and not (
over_indent == 4 and indent_next):
return(0, "E121 continuation line over-"
"indented for visual indent")
#:

#: E101 E117 W191
#: E101 W191


def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
#: E101 E117 W191 W504
#: E101 W191 W504
if ((row < 0 or self.moduleCount <= row or
col < 0 or self.moduleCount <= col)):
raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
#: E101 E101 E101 E101 E117 W191 W191 W191 W191 W191 W191
#: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191
if bar:
return(
start, 'E121 lines starting with a '
Expand All @@ -65,35 +65,35 @@ def long_function_name(
"bracket's line"
)
#
#: E101 E117 W191 W504
#: E101 W191 W504
# you want vertical alignment, so use a parens
if ((foo.bar("baz") and
foo.bar("frop")
)):
print "yes"
#: E101 E117 W191 W504
#: E101 W191 W504
# also ok, but starting to look like LISP
if ((foo.bar("baz") and
foo.bar("frop"))):
print "yes"
#: E101 E117 W191 W504
#: E101 W191 W504
if (a == 2 or
b == "abc def ghi"
"jkl mno"):
return True
#: E101 E117 W191 W504
#: E101 W191 W504
if (a == 2 or
b == """abc def ghi
jkl mno"""):
return True
#: W191:2:1 W191:3:1 E101:3:2 E117
#: W191:2:1 W191:3:1 E101:3:2
if length > options.max_line_length:
return options.max_line_length, \
"E501 line too long (%d characters)" % length


#
#: E101 E117 W191 W191 W504
#: E101 W191 W191 W504
if os.path.exists(os.path.join(path, PEP8_BIN)):
cmd = ([os.path.join(path, PEP8_BIN)] +
self._pep8_options(targetfile))
Expand All @@ -119,19 +119,19 @@ def long_function_name(
even though the noqa comment is not immediately after the string
''' + foo # noqa
#
#: E101 E117 W191
#: E101 W191
if foo is None and bar is "frop" and \
blah == 'yeah':
blah = 'yeahnah'


#
#: E117 W191 W191 W191
#: W191 W191 W191
if True:
foo(
1,
2)
#: E117 W191 W191 W191 W191 W191
#: W191 W191 W191 W191 W191
def test_keys(self):
"""areas.json - All regions are accounted for."""
expected = set([
Expand Down
4 changes: 2 additions & 2 deletions testsuite/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ def test_styleguide(self):
report = pycodestyle.StyleGuide().check_files([E11])
stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(len(stdout), report.total_errors)
self.assertEqual(report.total_errors, 20)
self.assertEqual(report.total_errors, 24)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new errors are:

pycodestyle/testsuite/E11.py:41:1: E302 expected 2 blank lines, found 0
pycodestyle/testsuite/E11.py:42:1: E101 indentation contains mixed spaces and tabs
pycodestyle/testsuite/E11.py:42:1: W191 indentation contains tabs
pycodestyle/testsuite/E11.py:42:3: E117 over-indented

self.assertFalse(sys.stderr)
self.reset()

# Passing the paths in the constructor gives same result
report = pycodestyle.StyleGuide(paths=[E11]).check_files()
stdout = sys.stdout.getvalue().splitlines()
self.assertEqual(len(stdout), report.total_errors)
self.assertEqual(report.total_errors, 20)
self.assertEqual(report.total_errors, 24)
self.assertFalse(sys.stderr)
self.reset()

Expand Down
2 changes: 1 addition & 1 deletion testsuite/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_check_simple(self):
stdout = stdout.splitlines()
self.assertEqual(errcode, 1)
self.assertFalse(stderr)
self.assertEqual(len(stdout), 20)
self.assertEqual(len(stdout), 24)
for line, num, col in zip(stdout, (3, 6, 6, 9, 12), (3, 6, 6, 1, 5)):
path, x, y, msg = line.split(':')
self.assertTrue(path.endswith(E11))
Expand Down