From 80a7a79ac31b0449bee9ec2dc8c0f4e1288a9670 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Fri, 31 May 2013 18:15:37 -0700 Subject: [PATCH] Add H402 doctest and other doc cleanups Add note to move H601 FIx docstrings for H902 and H902 Change-Id: I157ee4d08dd665611ac0d5417e7e54553be8be2c --- hacking/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hacking/core.py b/hacking/core.py index be21e6e2..7c3e0588 100755 --- a/hacking/core.py +++ b/hacking/core.py @@ -435,6 +435,8 @@ def hacking_docstring_one_line(physical_line, previous_logical): Okay: class Foo:\n pass\n '''This is not a docstring''' H402: def foo():\n '''This is not''' H402: def foo():\n '''Bad punctuation,''' + H402: def foo():\n '''Bad punctuation:''' + H402: def foo():\n '''Bad punctuation;''' H402: class Foo:\n '''Bad punctuation,''' """ #TODO(jogo) make this apply to multi line docstrings as well @@ -501,6 +503,7 @@ def hacking_no_cr(physical_line): # upstream fix H601 import os\r\nimport sys """ + #TODO(jogo): This should not be in H6xx, it should be in H9xx pos = physical_line.find('\r') if pos != -1 and pos == (len(physical_line) - 2): return (pos, "H601: Windows style line endings not allowed in code") @@ -587,6 +590,7 @@ def hacking_localization_strings(logical_line, tokens): Okay: _("This is fine") Okay: _("This is also fine %s") + Okay: _("So is this %s, %(foo)s") % {foo: 'foo'} H701: _('') H702: _("Bob" + " foo") H702: _("Bob %s" % foo) @@ -607,7 +611,7 @@ def hacking_localization_strings(logical_line, tokens): @flake8ext def hacking_is_not(logical_line): - r"""Check localization in line. + r"""Check for use of 'is not' for testing unequal identities. Okay: if x is not y:\n pass H901: if not X is Y @@ -622,7 +626,7 @@ def hacking_is_not(logical_line): @flake8ext def hacking_not_in(logical_line): - r"""Check localization in line. + r"""Check for use of "not in" for evaluating membership. Okay: if x not in y:\n pass Okay: if not (X in Y or X is Z):\n pass