Merge lp:~allenap/commandant/lint-and-such into lp:commandant

Proposed by Gavin Panella
Status: Merged
Merged at revision: 45
Proposed branch: lp:~allenap/commandant/lint-and-such
Merge into: lp:commandant
Prerequisite: lp:~allenap/commandant/test-failures-updated-bzrlib-possibly
Diff against target: 92 lines (+16/-10)
5 files modified
Makefile (+5/-1)
commandant/controller.py (+9/-7)
commandant/errors.py (+1/-1)
commandant/formatting.py (+1/-0)
commandant/tests/test_formatting.py (+0/-1)
To merge this branch: bzr merge lp:~allenap/commandant/lint-and-such
Reviewer Review Type Date Requested Status
Jamu Kakar Pending
Review via email: mp+122921@code.launchpad.net

Commit message

Correct lint as reported by flake8, which includes a PEP8 test.

There is now a "flake8" make target to run this against everything in commandant/, except mocker.py, and all warnings have been addressed.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

Thanks for the cleanup! I've modified the Makefile to have new 'pep8'
and 'lint' make targets. I'm not aware of flake8 and it seems that
pep8 reports more issues. One I'm not sure how to fix is this one, so
I've left it untouched for now:

$ make lint
commandant/commands.py:67:23: W602 deprecated form of raising exception
make: *** [pep8] Error 123

Revision history for this message
Gavin Panella (allenap) wrote :

> $ make lint
> commandant/commands.py:67:23: W602 deprecated form of raising exception
> make: *** [pep8] Error 123

I looked around for a non-deprecated approach to this for Python 2.x,
but I couldn't find anything. Python 3.x's BaseException has a
with_traceback() method, so it seems like 2.x has been left out in the
cold.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2009-12-27 21:00:22 +0000
3+++ Makefile 2012-09-05 18:30:25 +0000
4@@ -8,6 +8,11 @@
5 pyflakes:
6 @pyflakes commandant
7
8+flake8:
9+ @find commandant \
10+ -name '*.py' ! -path 'commandant/testing/mocker.py' \
11+ -print0 | xargs -r0 flake8 --max-line-length=80
12+
13 doc:
14 @pydoctor \
15 --project-name Commandant \
16@@ -31,4 +36,3 @@
17
18 release:
19 @python setup.py sdist
20-
21
22=== modified file 'commandant/controller.py'
23--- commandant/controller.py 2010-06-12 13:58:13 +0000
24+++ commandant/controller.py 2012-09-05 18:30:25 +0000
25@@ -144,20 +144,22 @@
26 file_mode = os.stat(file_path)[0]
27 if not os.path.isfile(file_path):
28 continue
29- if file_mode|stat.S_IEXEC == file_mode:
30+ if file_mode | stat.S_IEXEC == file_mode:
31 sanitized_name = filename.replace("_", "-")
32- class Executable(ExecutableCommand):
33- path = file_path
34- self.register_command(sanitized_name, Executable)
35+ executable = type(
36+ "Executable", (ExecutableCommand,),
37+ {"path": file_path})
38+ self.register_command(sanitized_name, executable)
39 elif filename.endswith(".py"):
40 command_module = import_module(filename, file_path,
41 package_path)
42 self.load_module(command_module)
43 elif filename.endswith(".txt"):
44 sanitized_name = filename.replace("_", "-")[:-4]
45- class Topic(FileHelpTopic):
46- path = file_path
47- self.register_help_topic(sanitized_name, Topic)
48+ topic = type(
49+ "Topic", (FileHelpTopic,),
50+ {"path": file_path})
51+ self.register_help_topic(sanitized_name, topic)
52 finally:
53 shutil.rmtree(package_path)
54
55
56=== modified file 'commandant/errors.py'
57--- commandant/errors.py 2010-06-12 13:58:13 +0000
58+++ commandant/errors.py 2012-09-05 18:30:25 +0000
59@@ -17,6 +17,7 @@
60
61 """Exception classes."""
62
63+
64 class CommandantError(StandardError):
65 """Base class for Commandant exceptions."""
66 pass
67@@ -25,4 +26,3 @@
68 class UsageError(CommandantError):
69 """Raised when too few command-line arguments are provided."""
70 pass
71-
72
73=== modified file 'commandant/formatting.py'
74--- commandant/formatting.py 2010-06-12 13:58:13 +0000
75+++ commandant/formatting.py 2012-09-05 18:30:25 +0000
76@@ -17,6 +17,7 @@
77
78 """Infrastructure for pretty-printing formatted output."""
79
80+
81 def print_columns(outf, rows, shrink_index=None, max_width=78, padding=2):
82 """Calculate optimal column widths and print C{rows} to C{outf}.
83
84
85=== modified file 'commandant/tests/test_formatting.py'
86--- commandant/tests/test_formatting.py 2009-07-12 09:40:25 +0000
87+++ commandant/tests/test_formatting.py 2012-09-05 18:30:25 +0000
88@@ -76,4 +76,3 @@
89 up
90 down
91 """)
92-

Subscribers

People subscribed via source and target branches