commit aa381a14380cb2bd06cee77088de7399f8302b88
Author: cypherpunks <cypherpunks(a)torproject.org>
Date: Tue Jul 7 15:54:06 2015 +0200
Remove the custom check for indentation with tabs.
The pep8 API has the same check which makes the custom check redundant.
Indentation with tabs errors are assigned error code W191.
---
run_tests.py | 2 +-
stem/util/test_tools.py | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/…
[View More]run_tests.py b/run_tests.py
index 47e977c..d82f38a 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -78,7 +78,7 @@ PYFLAKES_TASK = Task(
PEP8_TASK = Task(
'running pep8',
stem.util.test_tools.stylistic_issues,
- args = (SRC_PATHS, True, True, True, True, True),
+ args = (SRC_PATHS, True, True, True, True),
is_required = False,
print_result = False,
)
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index af9c944..2694327 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -116,7 +116,7 @@ def is_pep8_available():
return False
-def stylistic_issues(paths, check_two_space_indents = False, check_newlines = False, check_trailing_whitespace = False, check_exception_keyword = False, prefer_single_quotes = False):
+def stylistic_issues(paths, check_newlines = False, check_trailing_whitespace = False, check_exception_keyword = False, prefer_single_quotes = False):
"""
Checks for stylistic issues that are an issue according to the parts of PEP8
we conform to. You can suppress PEP8 issues by making a 'test' configuration
@@ -161,8 +161,6 @@ def stylistic_issues(paths, check_two_space_indents = False, check_newlines = Fa
Added the prefer_single_quotes option.
:param list paths: paths to search for stylistic issues
- :param bool check_two_space_indents: check for two space indentations and
- that no tabs snuck in
:param bool check_newlines: check that we have standard newlines (\\n), not
windows (\\r\\n) nor classic mac (\\r)
:param bool check_trailing_whitespace: check that our lines don't end with
@@ -194,7 +192,7 @@ def stylistic_issues(paths, check_two_space_indents = False, check_newlines = Fa
style_checker = pep8.StyleGuide(ignore = CONFIG['pep8.ignore'], reporter = StyleReport)
style_checker.check_files(list(_python_files(paths)))
- if check_two_space_indents or check_newlines or check_trailing_whitespace or check_exception_keyword:
+ if check_newlines or check_trailing_whitespace or check_exception_keyword:
for path in _python_files(paths):
with open(path) as f:
file_contents = f.read()
@@ -212,9 +210,7 @@ def stylistic_issues(paths, check_two_space_indents = False, check_newlines = Fa
if '"""' in content:
is_block_comment = not is_block_comment
- if check_two_space_indents and '\t' in whitespace:
- issues.setdefault(path, []).append(Issue(index + 1, 'indentation has a tab', line))
- elif check_newlines and '\r' in content:
+ if check_newlines and '\r' in content:
issues.setdefault(path, []).append(Issue(index + 1, 'contains a windows newline', line))
elif check_trailing_whitespace and content != content.rstrip():
issues.setdefault(path, []).append(Issue(index + 1, 'line has trailing whitespace', line))
[View Less]
commit c8cd4fc7f17c239384b1985ae8ae9370367ca394
Author: cypherpunks <cypherpunks(a)torproject.org>
Date: Tue Jul 7 15:35:07 2015 +0200
Fix the format of PEP8 issue lines.
According to commit d14c2803eca669022a64a5caf16699ce77e2fb70, an issue line
consists of three elements; the line number, the error message and the actual
line from the file that has the error. This commit fixes PEP8 issue lines where
the error message and line were equal.
Additionally,…
[View More] this commit removes the duplicate error code in PEP8 issue lines
and adds parentheses around the line to improve readability.
---
run_tests.py | 2 +-
stem/util/test_tools.py | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/run_tests.py b/run_tests.py
index d988900..47e977c 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -326,7 +326,7 @@ def _print_static_issues(static_check_issues):
for line_number in sorted(line_to_issues.keys()):
for msg, line in line_to_issues[line_number]:
line_count = '%-4s' % line_number
- println(' line %s - %-40s %s' % (line_count, msg, line.strip()))
+ println(' line %s - %-40s (%s)' % (line_count, msg, line.strip()))
println()
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index d6a81c4..af9c944 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -188,7 +188,8 @@ def stylistic_issues(paths, check_two_space_indents = False, check_newlines = Fa
code = super(StyleReport, self).error(line_number, offset, text, check)
if code:
- issues.setdefault(self.filename, []).append(Issue(line_number, '%s %s' % (code, text), text))
+ line = linecache.getline(self.filename, line_number)
+ issues.setdefault(self.filename, []).append(Issue(line_number, text, line))
style_checker = pep8.StyleGuide(ignore = CONFIG['pep8.ignore'], reporter = StyleReport)
style_checker.check_files(list(_python_files(paths)))
[View Less]
commit 268cfe504566d1684c0143f9f32c6c68c5f198bc
Author: cypherpunks <cypherpunks(a)torproject.org>
Date: Tue Jul 7 16:33:53 2015 +0200
Remove the custom check for trailing whitespace.
The pep8 API has the same check which makes the custom check redundant.
Trailing whitespace errors are assigned error code W291.
---
run_tests.py | 2 +-
stem/util/test_tools.py | 8 ++------
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/run_tests.…
[View More]py b/run_tests.py
index d82f38a..91c0adf 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -78,7 +78,7 @@ PYFLAKES_TASK = Task(
PEP8_TASK = Task(
'running pep8',
stem.util.test_tools.stylistic_issues,
- args = (SRC_PATHS, True, True, True, True),
+ args = (SRC_PATHS, True, True, True),
is_required = False,
print_result = False,
)
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index 2694327..e36f5fa 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -116,7 +116,7 @@ def is_pep8_available():
return False
-def stylistic_issues(paths, check_newlines = False, check_trailing_whitespace = False, check_exception_keyword = False, prefer_single_quotes = False):
+def stylistic_issues(paths, check_newlines = False, check_exception_keyword = False, prefer_single_quotes = False):
"""
Checks for stylistic issues that are an issue according to the parts of PEP8
we conform to. You can suppress PEP8 issues by making a 'test' configuration
@@ -163,8 +163,6 @@ def stylistic_issues(paths, check_newlines = False, check_trailing_whitespace =
:param list paths: paths to search for stylistic issues
:param bool check_newlines: check that we have standard newlines (\\n), not
windows (\\r\\n) nor classic mac (\\r)
- :param bool check_trailing_whitespace: check that our lines don't end with
- trailing whitespace
:param bool check_exception_keyword: checks that we're using 'as' for
exceptions rather than a comma
:param bool prefer_single_quotes: standardize on using single rather than
@@ -192,7 +190,7 @@ def stylistic_issues(paths, check_newlines = False, check_trailing_whitespace =
style_checker = pep8.StyleGuide(ignore = CONFIG['pep8.ignore'], reporter = StyleReport)
style_checker.check_files(list(_python_files(paths)))
- if check_newlines or check_trailing_whitespace or check_exception_keyword:
+ if check_newlines or check_exception_keyword:
for path in _python_files(paths):
with open(path) as f:
file_contents = f.read()
@@ -212,8 +210,6 @@ def stylistic_issues(paths, check_newlines = False, check_trailing_whitespace =
if check_newlines and '\r' in content:
issues.setdefault(path, []).append(Issue(index + 1, 'contains a windows newline', line))
- elif check_trailing_whitespace and content != content.rstrip():
- issues.setdefault(path, []).append(Issue(index + 1, 'line has trailing whitespace', line))
elif check_exception_keyword and content.lstrip().startswith('except') and content.endswith(', exc:'):
# Python 2.6 - 2.7 supports two forms for exceptions...
#
[View Less]