summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-12-26 00:55:06 +0100
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-12-26 00:55:06 +0100
commit5d7dbef4f904123b40a9b76a41fb08aa1e3a1d03 (patch)
tree9d436106d9a0cd5fe5df1f3fcee863f8f534aec8
parent44e8c9171aa2231a2b31c9488e2108c0170eed41 (diff)
downloadpep8-5d7dbef4f904123b40a9b76a41fb08aa1e3a1d03.tar.gz
Allow sphinx.ext.autodoc syntax for comments. Issue #110
-rw-r--r--CHANGES.txt2
-rwxr-xr-xpep8.py3
-rw-r--r--testsuite/E26.py7
3 files changed, 10 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index ea141f9..dbf3dd1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,7 +5,7 @@ Changelog
1.x (unreleased)
----------------
-* ...
+* Allow sphinx.ext.autodoc syntax for comments. (Issue #110)
1.4 (2012-12-22)
diff --git a/pep8.py b/pep8.py
index d558ed4..7afe96f 100755
--- a/pep8.py
+++ b/pep8.py
@@ -796,7 +796,8 @@ def whitespace_before_inline_comment(logical_line, tokens):
if prev_end[0] == start[0] and start[1] < prev_end[1] + 2:
yield (prev_end,
"E261 at least two spaces before inline comment")
- if text.startswith('# ') or not text.startswith('# '):
+ symbol, sp, comment = text.partition(' ')
+ if symbol not in ('#', '#:') or comment[:1].isspace():
yield start, "E262 inline comment should start with '# '"
elif token_type != tokenize.NL:
prev_end = end
diff --git a/testsuite/E26.py b/testsuite/E26.py
index b4f7af7..984efb5 100644
--- a/testsuite/E26.py
+++ b/testsuite/E26.py
@@ -4,3 +4,10 @@ pass # an inline comment
x = x + 1 #Increment x
#: E262
x = x + 1 # Increment x
+#: E262
+x = y + 1 #: Increment x
+#: Okay
+pass # an inline comment
+x = x + 1 # Increment x
+y = y + 1 #: Increment x
+#: