Merge lp:~rackspace-titan/nova/pylint-issues-ameade into lp:~hudson-openstack/nova/trunk

Proposed by Alex Meade
Status: Merged
Approved by: Devin Carlen
Approved revision: 1156
Merged at revision: 1162
Proposed branch: lp:~rackspace-titan/nova/pylint-issues-ameade
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 227 lines (+21/-49)
10 files modified
nova/api/direct.py (+1/-1)
nova/api/ec2/admin.py (+0/-4)
nova/api/openstack/extensions.py (+2/-2)
nova/api/openstack/views/limits.py (+0/-9)
nova/db/sqlalchemy/api.py (+1/-1)
nova/db/sqlalchemy/models.py (+1/-0)
nova/tests/xenapi/stubs.py (+2/-16)
nova/twistd.py (+3/-3)
nova/utils.py (+10/-8)
nova/virt/xenapi/fake.py (+1/-5)
To merge this branch: bzr merge lp:~rackspace-titan/nova/pylint-issues-ameade
Reviewer Review Type Date Requested Status
Brian Lamar (community) Approve
Devin Carlen (community) Approve
Josh Kearney (community) Approve
Review via email: mp+63575@code.launchpad.net

Description of the change

Cleaned up some of the larger pylint errors. Set to ignore some lines that pylint just couldn't understand.

To post a comment you must log in.
Revision history for this message
Brian Lamar (blamar) wrote :

Can you give a brief explanation on why the move from super() calls to explicit __init__ calls? Also, remove commented code. Thanks!

review: Needs Fixing
Revision history for this message
Todd Willey (xtoddx) wrote :

No reason to keep old code around but commented out (line 34, 44).

I also like keeping the NotImplementedError methods around. Grep is nicer than having to read code to find what is missing.

1155. By Alex Meade

Removed commented code

Revision history for this message
Alex Meade (alex-meade) wrote :

@Brian pylint complains when using super with old style classes because Python's Super is considered harmful.

@Todd the functions that were not implemented got implemented and the old stub methods that returned NotImplementedError were not removed. Take a look at the file in trunk if I'm not making sense.

Thanks for the quick reviews guys :)

Revision history for this message
Josh Kearney (jk0) wrote :

You're going to want to use 2 spaces for inline pylint comments (ex: foo # bar), otherwise this merge will not pass PEP8.

review: Needs Fixing
1156. By Alex Meade

pep8

Revision history for this message
Alex Meade (alex-meade) wrote :

Fixed pep8

Revision history for this message
Josh Kearney (jk0) wrote :

Looks good to me.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Brian Lamar (blamar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/direct.py'
2--- nova/api/direct.py 2011-05-19 20:16:06 +0000
3+++ nova/api/direct.py 2011-06-07 19:19:28 +0000
4@@ -324,7 +324,7 @@
5
6 def __init__(self, proxy):
7 self._proxy = proxy
8- if not self.__doc__:
9+ if not self.__doc__: # pylint: disable=E0203
10 self.__doc__ = proxy.__doc__
11 if not self._allowed:
12 self._allowed = []
13
14=== modified file 'nova/api/ec2/admin.py'
15--- nova/api/ec2/admin.py 2011-06-02 21:23:05 +0000
16+++ nova/api/ec2/admin.py 2011-06-07 19:19:28 +0000
17@@ -324,7 +324,3 @@
18 rv.append(host_dict(host, compute, instances, volume, volumes,
19 now))
20 return {'hosts': rv}
21-
22- def describe_host(self, _context, name, **_kwargs):
23- """Returns status info for single node."""
24- return host_dict(db.host_get(name))
25
26=== modified file 'nova/api/openstack/extensions.py'
27--- nova/api/openstack/extensions.py 2011-05-20 19:29:23 +0000
28+++ nova/api/openstack/extensions.py 2011-06-07 19:19:28 +0000
29@@ -137,7 +137,7 @@
30
31 def __init__(self, application):
32 controller = ActionExtensionController(application)
33- super(ActionExtensionResource, self).__init__(controller)
34+ wsgi.Resource.__init__(self, controller)
35
36 def add_action(self, action_name, handler):
37 self.controller.add_action(action_name, handler)
38@@ -164,7 +164,7 @@
39
40 def __init__(self, application):
41 controller = RequestExtensionController(application)
42- super(RequestExtensionResource, self).__init__(controller)
43+ wsgi.Resource.__init__(self, controller)
44
45 def add_handler(self, handler):
46 self.controller.add_handler(handler)
47
48=== modified file 'nova/api/openstack/views/limits.py'
49--- nova/api/openstack/views/limits.py 2011-05-23 15:23:40 +0000
50+++ nova/api/openstack/views/limits.py 2011-06-07 19:19:28 +0000
51@@ -29,9 +29,6 @@
52 def _build_rate_limit(self, rate_limit):
53 raise NotImplementedError()
54
55- def _build_absolute_limits(self, absolute_limit):
56- raise NotImplementedError()
57-
58 def build(self, rate_limits, absolute_limits):
59 rate_limits = self._build_rate_limits(rate_limits)
60 absolute_limits = self._build_absolute_limits(absolute_limits)
61@@ -67,12 +64,6 @@
62 limits[name] = value
63 return limits
64
65- def _build_rate_limits(self, rate_limits):
66- raise NotImplementedError()
67-
68- def _build_rate_limit(self, rate_limit):
69- raise NotImplementedError()
70-
71
72 class ViewBuilderV10(ViewBuilder):
73 """Openstack API v1.0 limits view builder."""
74
75=== modified file 'nova/db/sqlalchemy/api.py'
76--- nova/db/sqlalchemy/api.py 2011-06-06 20:08:58 +0000
77+++ nova/db/sqlalchemy/api.py 2011-06-07 19:19:28 +0000
78@@ -743,7 +743,7 @@
79 filter_by(instance_id=instance_id).\
80 filter_by(deleted=False)
81 if not rv:
82- raise exception.NoFloatingIpsFoundForInstance(instance_id=instance_id)
83+ raise exception.NoFixedIpsFoundForInstance(instance_id=instance_id)
84 return rv
85
86
87
88=== modified file 'nova/db/sqlalchemy/models.py'
89--- nova/db/sqlalchemy/models.py 2011-06-03 15:11:01 +0000
90+++ nova/db/sqlalchemy/models.py 2011-06-07 19:19:28 +0000
91@@ -46,6 +46,7 @@
92 updated_at = Column(DateTime, onupdate=utils.utcnow)
93 deleted_at = Column(DateTime)
94 deleted = Column(Boolean, default=False)
95+ metadata = None
96
97 def save(self, session=None):
98 """Save this object."""
99
100=== modified file 'nova/tests/xenapi/stubs.py'
101--- nova/tests/xenapi/stubs.py 2011-05-26 19:27:27 +0000
102+++ nova/tests/xenapi/stubs.py 2011-06-07 19:19:28 +0000
103@@ -42,20 +42,6 @@
104
105 stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
106
107- def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref,
108- original_parent_uuid):
109- from nova.virt.xenapi.fake import create_vdi
110- name_label = "instance-%s" % instance_id
111- #TODO: create fake SR record
112- sr_ref = "fakesr"
113- vdi_ref = create_vdi(name_label=name_label, read_only=False,
114- sr_ref=sr_ref, sharable=False)
115- vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
116- vdi_uuid = vdi_rec['uuid']
117- return vdi_uuid
118-
119- stubs.Set(vm_utils.VMHelper, 'fetch_image', fake_fetch_image)
120-
121 def fake_parse_xmlrpc_value(val):
122 return val
123
124@@ -251,10 +237,10 @@
125 def __init__(self, uri):
126 super(FakeSessionForMigrationTests, self).__init__(uri)
127
128- def VDI_get_by_uuid(*args):
129+ def VDI_get_by_uuid(self, *args):
130 return 'hurr'
131
132- def VDI_resize_online(*args):
133+ def VDI_resize_online(self, *args):
134 pass
135
136 def VM_start(self, _1, ref, _2, _3):
137
138=== modified file 'nova/twistd.py'
139--- nova/twistd.py 2011-02-21 21:46:41 +0000
140+++ nova/twistd.py 2011-06-07 19:19:28 +0000
141@@ -78,7 +78,7 @@
142 self._absorbParameters()
143 self._absorbHandlers()
144
145- super(TwistedOptionsToFlags, self).__init__()
146+ wrapped.__init__(self)
147
148 def _absorbFlags(self):
149 twistd_flags = []
150@@ -163,12 +163,12 @@
151 def parseArgs(self, *args):
152 # TODO(termie): figure out a decent way of dealing with args
153 #return
154- super(TwistedOptionsToFlags, self).parseArgs(*args)
155+ wrapped.parseArgs(self, *args)
156
157 def postOptions(self):
158 self._doHandlers()
159
160- super(TwistedOptionsToFlags, self).postOptions()
161+ wrapped.postOptions(self)
162
163 def __getitem__(self, key):
164 key = key.replace('-', '_')
165
166=== modified file 'nova/utils.py'
167--- nova/utils.py 2011-06-03 15:11:01 +0000
168+++ nova/utils.py 2011-06-07 19:19:28 +0000
169@@ -142,24 +142,26 @@
170 env = os.environ.copy()
171 if addl_env:
172 env.update(addl_env)
173+ _PIPE = subprocess.PIPE # pylint: disable=E1101
174 obj = subprocess.Popen(cmd,
175- stdin=subprocess.PIPE,
176- stdout=subprocess.PIPE,
177- stderr=subprocess.PIPE,
178+ stdin=_PIPE,
179+ stdout=_PIPE,
180+ stderr=_PIPE,
181 env=env)
182 result = None
183 if process_input is not None:
184 result = obj.communicate(process_input)
185 else:
186 result = obj.communicate()
187- obj.stdin.close()
188- if obj.returncode:
189- LOG.debug(_('Result was %s') % obj.returncode)
190+ obj.stdin.close() # pylint: disable=E1101
191+ _returncode = obj.returncode # pylint: disable=E1101
192+ if _returncode:
193+ LOG.debug(_('Result was %s') % _returncode)
194 if type(check_exit_code) == types.IntType \
195- and obj.returncode != check_exit_code:
196+ and _returncode != check_exit_code:
197 (stdout, stderr) = result
198 raise exception.ProcessExecutionError(
199- exit_code=obj.returncode,
200+ exit_code=_returncode,
201 stdout=stdout,
202 stderr=stderr,
203 cmd=' '.join(cmd))
204
205=== modified file 'nova/virt/xenapi/fake.py'
206--- nova/virt/xenapi/fake.py 2011-06-02 21:23:05 +0000
207+++ nova/virt/xenapi/fake.py 2011-06-07 19:19:28 +0000
208@@ -340,10 +340,6 @@
209 return
210 db_ref['xenstore_data'][key] = None
211
212- def network_get_all_records_where(self, _1, _2):
213- # TODO (salvatore-orlando): filter table on _2
214- return _db_content['network']
215-
216 def VM_add_to_xenstore_data(self, _1, vm_ref, key, value):
217 db_ref = _db_content['VM'][vm_ref]
218 if not 'xenstore_data' in db_ref:
219@@ -354,7 +350,7 @@
220 #Always return 12GB available
221 return 12 * 1024 * 1024 * 1024
222
223- def host_call_plugin(*args):
224+ def host_call_plugin(self, *args):
225 return 'herp'
226
227 def network_get_all_records_where(self, _1, filter):