Merge lp:~javier.collado/checkbox-core/staticmethods into lp:checkbox-core

Proposed by Javier Collado
Status: Merged
Merged at revision: 15
Proposed branch: lp:~javier.collado/checkbox-core/staticmethods
Merge into: lp:checkbox-core
Diff against target: 112 lines (+18/-18)
4 files modified
checkbox/journal/multi.py (+8/-8)
checkbox/message/signal.py (+2/-2)
checkbox/process/args.py (+6/-6)
checkbox/process/env.py (+2/-2)
To merge this branch: bzr merge lp:~javier.collado/checkbox-core/staticmethods
Reviewer Review Type Date Requested Status
Marc Tardif Approve
Review via email: mp+103279@code.launchpad.net

Description of the change

Those class methods that didn't actually used the cls parameter, have been changed to be static methods.

To post a comment you must log in.
Revision history for this message
Marc Tardif (cr3) wrote :

This is definately in the right direction where I would eventually like to see class methods replaced with static methods, and static methods replaced by functions. This would be consistent with what Guido said [1]: Ironically, there are now no known uses for class methods in the Python distribution (other than in the test suite). I might even get rid of classmethod in a future release if no good use for it can be found!

However, these changes should not be done systematically; if a class method doesn't happen to use the class argument, that doesn't necessarily mean it makes sense to make it a function. So, some class methods might make more sense to be expressed as just methods whereas others as functions.

1. http://www.python.org/download/releases/2.2/descrintro/

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'checkbox/journal/multi.py'
--- checkbox/journal/multi.py 2012-04-23 19:36:19 +0000
+++ checkbox/journal/multi.py 2012-04-24 13:33:32 +0000
@@ -54,8 +54,8 @@
5454
55class Multi:55class Multi:
5656
57 @classmethod57 @staticmethod
58 def truncateFilenames(cls, filenames):58 def truncateFilenames(filenames):
59 """Static method to truncate the given journal files to zero length."""59 """Static method to truncate the given journal files to zero length."""
60 for filename in filenames:60 for filename in filenames:
61 if os.acess(filename, os.F_OK):61 if os.acess(filename, os.F_OK):
@@ -67,8 +67,8 @@
67 if fd_close(fd) == -1:67 if fd_close(fd) == -1:
68 logging.info("Can't close %s", filename)68 logging.info("Can't close %s", filename)
6969
70 @classmethod70 @staticmethod
71 def filenameToLogicalLines(cls, filename):71 def filenameToLogicalLines(filename):
72 """Static method to read the specified file, break it into lines,72 """Static method to read the specified file, break it into lines,
73 and combine them into logical lines.73 and combine them into logical lines.
7474
@@ -171,8 +171,8 @@
171171
172 return journal172 return journal
173173
174 @classmethod174 @staticmethod
175 def loadFilenamesFromStoreSubmitFilename(cls, submit_filename, directory):175 def loadFilenamesFromStoreSubmitFilename(submit_filename, directory):
176 """ Gets the journal files from a stored submit file.176 """ Gets the journal files from a stored submit file.
177177
178 :param submit_filename: The submit file name.178 :param submit_filename: The submit file name.
@@ -293,8 +293,8 @@
293293
294 return list(values)294 return list(values)
295295
296 @classmethod296 @staticmethod
297 def _getParamFromSubmitLine(cls, line, param):297 def _getParamFromSubmitLine(line, param):
298 lexer = Lexer(line)298 lexer = Lexer(line)
299 token = Token()299 token = Token()
300300
301301
=== modified file 'checkbox/message/signal.py'
--- checkbox/message/signal.py 2012-04-23 19:36:19 +0000
+++ checkbox/message/signal.py 2012-04-24 13:33:32 +0000
@@ -29,8 +29,8 @@
2929
30class Signal:30class Signal:
3131
32 @classmethod32 @staticmethod
33 def find(cls, record, name, default=-1):33 def find(record, name, default=-1):
34 if not record:34 if not record:
35 return -135 return -1
3636
3737
=== modified file 'checkbox/process/args.py'
--- checkbox/process/args.py 2012-04-23 19:36:19 +0000
+++ checkbox/process/args.py 2012-04-24 13:33:32 +0000
@@ -50,8 +50,8 @@
50 else:50 else:
51 return True51 return True
5252
53 @classmethod53 @staticmethod
54 def quotedToRaw(cls, quoted):54 def quotedToRaw(quoted):
55 if not quoted:55 if not quoted:
56 return True56 return True
5757
@@ -98,8 +98,8 @@
9898
99 return raw99 return raw
100100
101 @classmethod101 @staticmethod
102 def argToRaw(cls, arg, raw=""):102 def argToRaw(arg, raw=""):
103 if raw:103 if raw:
104 raw += " "104 raw += " "
105105
@@ -136,8 +136,8 @@
136136
137 return raw137 return raw
138138
139 @classmethod139 @staticmethod
140 def splitRaw(cls, raw, args):140 def splitRaw(raw, args):
141 if not raw:141 if not raw:
142 return True142 return True
143143
144144
=== modified file 'checkbox/process/env.py'
--- checkbox/process/env.py 2012-04-23 19:36:19 +0000
+++ checkbox/process/env.py 2012-04-24 13:33:32 +0000
@@ -93,6 +93,6 @@
93 else:93 else:
94 return True94 return True
9595
96 @classmethod96 @staticmethod
97 def quotedToRaw(cls, quoted):97 def quotedToRaw(quoted):
98 return Args.quotedToRaw(quoted)98 return Args.quotedToRaw(quoted)

Subscribers

People subscribed via source and target branches

to all changes: