Merge lp:~zomux/twistedchecker/make-epydoc-optional into lp:~twistedchecker-dev/twistedchecker/trunk

Proposed by raphael shu
Status: Merged
Merged at revision: 29
Proposed branch: lp:~zomux/twistedchecker/make-epydoc-optional
Merge into: lp:~twistedchecker-dev/twistedchecker/trunk
Diff against target: 89 lines (+19/-2)
4 files modified
twistedchecker/checkers/docstring.py (+1/-1)
twistedchecker/core/runner.py (+10/-1)
twistedchecker/functionaltests/docstring_pass.py (+7/-0)
twistedchecker/test/test_runner.py (+1/-0)
To merge this branch: bzr merge lp:~zomux/twistedchecker/make-epydoc-optional
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
Review via email: mp+120320@code.launchpad.net

Description of the change

Added an option 'strict-epydoc' for enabling checking '@type' and '@rtype' in docstring.

To post a comment you must log in.
29. By raphael shu

make sure a method has return value when warn 'missing @return'

Revision history for this message
Jonathan Lange (jml) wrote :

Great :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'twistedchecker/checkers/docstring.py'
2--- twistedchecker/checkers/docstring.py 2012-07-24 13:40:33 +0000
3+++ twistedchecker/checkers/docstring.py 2012-08-20 04:17:22 +0000
4@@ -161,7 +161,7 @@
5 """
6 returnFound = False
7 for subnode in node.body:
8- if type(subnode) == node_classes.Return:
9+ if type(subnode) == node_classes.Return and subnode.value:
10 returnFound = True
11 break
12 return returnFound
13
14=== modified file 'twistedchecker/core/runner.py'
15--- twistedchecker/core/runner.py 2012-08-17 08:32:52 +0000
16+++ twistedchecker/core/runner.py 2012-08-20 04:17:22 +0000
17@@ -18,6 +18,7 @@
18 """
19 outputStream = None
20 linter = None
21+ allowOptions = None
22 # Customized checkers.
23 checkers = ("header.HeaderChecker",
24 "modulename.ModuleNameChecker",
25@@ -39,6 +40,7 @@
26 """
27 Initialize C{PyLinter} object, and load configuration file.
28 """
29+ self.allowOptions = True
30 self.linter = PyLinter(self._makeOptions())
31 # register standard checkers.
32 self.linter.load_default_plugins()
33@@ -61,7 +63,6 @@
34 self.setOutput(sys.stdout)
35 # set default reporter to limited reporter
36 self.setReporter(LimitedReporter(allowedMessages))
37-
38
39
40 def _makeOptions(self):
41@@ -76,6 +77,11 @@
42 "help": "Set comparing result file to automatically "
43 "generate a diff."}
44 ),
45+ ('strict-epydoc',
46+ {'type': 'yn', 'metavar': '<y_or_n>',
47+ 'default': False,
48+ 'help': "Check '@type' and '@rtype' in epydoc."}
49+ ),
50 )
51
52
53@@ -296,6 +302,9 @@
54 raise
55 if not args:
56 self.displayHelp()
57+ # Check for 'strict-epydoc' option.
58+ if self.allowOptions and not self.linter.option_value("strict-epydoc"):
59+ map(self.linter.disable, ["W9203", "W9205"])
60 # check for diff option.
61 if self.diffOption:
62 self.prepareDiff()
63
64=== modified file 'twistedchecker/functionaltests/docstring_pass.py'
65--- twistedchecker/functionaltests/docstring_pass.py 2012-07-18 05:19:07 +0000
66+++ twistedchecker/functionaltests/docstring_pass.py 2012-08-20 04:17:22 +0000
67@@ -55,3 +55,10 @@
68 """
69 def k():
70 pass
71+
72+
73+ def f(self):
74+ """
75+ A method returns nothing.
76+ """
77+ return
78
79=== modified file 'twistedchecker/test/test_runner.py'
80--- twistedchecker/test/test_runner.py 2012-08-17 08:32:52 +0000
81+++ twistedchecker/test/test_runner.py 2012-08-20 04:17:22 +0000
82@@ -214,6 +214,7 @@
83 msg="could not find resultfile:\n%s" % pathResultFile)
84 self.clearOutputStream()
85 runner = Runner()
86+ runner.allowOptions = False
87 runner.setOutput(self.outputStream)
88 # set the reporter to C{twistedchecker.reporters.test.TestReporter}
89 runner.setReporter(TestReporter())

Subscribers

People subscribed via source and target branches

to all changes: