Merge ~powersj/cloud-init:enable-pylint into cloud-init:master

Proposed by Joshua Powers
Status: Merged
Merged at revision: 35cf3415f9748c880db4d3c004f3410c3aa2cab2
Proposed branch: ~powersj/cloud-init:enable-pylint
Merge into: cloud-init:master
Diff against target: 160 lines (+56/-9)
7 files modified
.pylintrc (+39/-0)
cloudinit/net/network_state.py (+3/-2)
cloudinit/sources/DataSourceAltCloud.py (+1/-2)
cloudinit/sources/DataSourceOpenNebula.py (+2/-2)
cloudinit/sources/__init__.py (+1/-1)
cloudinit/url_helper.py (+1/-1)
tox.ini (+9/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+320560@code.launchpad.net

Commit message

test: enable pylint support in tox

Description of the change

Why enable pylint?
pylint has the ability to catch errors that pyflakes/flake8 simply wont. pylint sets the bar higher for what can get accepted in terms of quality.

This set of commits enables pylint to run without errors. This does not add it to the list of tests when running tox as I think that is something up for discussion. Please review the configuration and the changes to the code.

There are a number of legit errors that I have updated the code to avoid those errors. However, there are two places where a variable was changes from being instantiated as None to {}. This is due to pylint stating how a None object cannot be check for in (e.g. 'my_key' in variable, if variable is None). I really, really do not want to be breaking some existing infrastructure.

pylint output:
https://paste.ubuntu.com/24224371/

tox clean:
https://paste.ubuntu.com/24224366/

Integration test using Xenial:
https://paste.ubuntu.com/24224456/

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.pylintrc b/.pylintrc
0new file mode 1006440new file mode 100644
index 0000000..783c1bb
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,39 @@
1[MASTER]
2
3# --go-faster, use multiple processes to speed up Pylint
4jobs=4
5
6
7[MESSAGES CONTROL]
8
9# Errors only
10disable=C, F, I, R, W
11
12
13[REPORTS]
14
15# Set the output format. Available formats are text, parseable, colorized, msvs
16output-format=colorized
17
18# Just the errors please, no full report
19reports=no
20
21
22[TYPECHECK]
23
24# List of module names for which member attributes should not be checked
25# (useful for modules/projects where namespaces are manipulated during runtime
26# and thus existing member attributes cannot be deduced by static analysis. It
27# supports qualified module names, as well as Unix pattern matching.
28ignored-modules=six.moves,pkg_resources
29
30# List of class names for which member attributes should not be checked (useful
31# for classes with dynamically set attributes). This supports the use of
32# qualified names.
33ignored-classes=optparse.Values,thread._local,_thread._local,Renderer
34
35# List of members which are set dynamically and missed by pylint inference
36# system, and so shouldn't trigger E1101 when accessed. Python regular
37# expressions are accepted.
38generated-members=types,http.client,command_handlers
39
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index 701aaa4..692b600 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -214,7 +214,7 @@ class NetworkStateInterpreter(object):
214 return util.yaml_dumps(self._network_state)214 return util.yaml_dumps(self._network_state)
215215
216 def as_dict(self):216 def as_dict(self):
217 return {'version': self.version, 'config': self.config}217 return {'version': self._version, 'config': self._config}
218218
219 def get_network_state(self):219 def get_network_state(self):
220 ns = self.network_state220 ns = self.network_state
@@ -611,7 +611,8 @@ class NetworkStateInterpreter(object):
611 self.handle_vlan(vlan_cmd)611 self.handle_vlan(vlan_cmd)
612612
613 def handle_wifis(self, command):613 def handle_wifis(self, command):
614 raise NotImplemented('NetworkState V2: Skipping wifi configuration')614 raise NotImplementedError("NetworkState V2: "
615 "Skipping wifi configuration")
615616
616 def _v2_common(self, cfg):617 def _v2_common(self, cfg):
617 LOG.debug('v2_common: handling config:\n%s', cfg)618 LOG.debug('v2_common: handling config:\n%s', cfg)
diff --git a/cloudinit/sources/DataSourceAltCloud.py b/cloudinit/sources/DataSourceAltCloud.py
index c2b0eac..8528fa1 100644
--- a/cloudinit/sources/DataSourceAltCloud.py
+++ b/cloudinit/sources/DataSourceAltCloud.py
@@ -201,8 +201,7 @@ class DataSourceAltCloud(sources.DataSource):
201 util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd), _err)201 util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd), _err)
202 return False202 return False
203 except OSError as _err:203 except OSError as _err:
204 util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd),204 util.logexc(LOG, 'Failed command: %s\n%s', ' '.join(cmd), _err)
205 _err.message)
206 return False205 return False
207206
208 try:207 try:
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
index 1f1baf4..cd75e6e 100644
--- a/cloudinit/sources/DataSourceOpenNebula.py
+++ b/cloudinit/sources/DataSourceOpenNebula.py
@@ -286,12 +286,12 @@ def parse_shell_config(content, keylist=None, bash=None, asuser=None,
286 output = output[0:-1] # remove trailing null286 output = output[0:-1] # remove trailing null
287287
288 # go through output. First _start_ is for 'preset', second for 'target'.288 # go through output. First _start_ is for 'preset', second for 'target'.
289 # Add to target only things were changed and not in volitile289 # Add to ret only things were changed and not in excluded.
290 for line in output.split("\x00"):290 for line in output.split("\x00"):
291 try:291 try:
292 (key, val) = line.split("=", 1)292 (key, val) = line.split("=", 1)
293 if target is preset:293 if target is preset:
294 target[key] = val294 preset[key] = val
295 elif (key not in excluded and295 elif (key not in excluded and
296 (key in keylist_in or preset.get(key) != val)):296 (key in keylist_in or preset.get(key) != val)):
297 ret[key] = val297 ret[key] = val
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index 1829450..5c99437 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -50,7 +50,7 @@ class DataSource(object):
50 self.distro = distro50 self.distro = distro
51 self.paths = paths51 self.paths = paths
52 self.userdata = None52 self.userdata = None
53 self.metadata = None53 self.metadata = {}
54 self.userdata_raw = None54 self.userdata_raw = None
55 self.vendordata = None55 self.vendordata = None
56 self.vendordata_raw = None56 self.vendordata_raw = None
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
index 312b046..2f6a158 100644
--- a/cloudinit/url_helper.py
+++ b/cloudinit/url_helper.py
@@ -45,7 +45,7 @@ try:
45 from distutils.version import LooseVersion45 from distutils.version import LooseVersion
46 import pkg_resources46 import pkg_resources
47 _REQ = pkg_resources.get_distribution('requests')47 _REQ = pkg_resources.get_distribution('requests')
48 _REQ_VER = LooseVersion(_REQ.version)48 _REQ_VER = LooseVersion(_REQ.version) # pylint: disable=no-member
49 if _REQ_VER >= LooseVersion('0.8.8'):49 if _REQ_VER >= LooseVersion('0.8.8'):
50 SSL_ENABLED = True50 SSL_ENABLED = True
51 if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'):51 if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'):
diff --git a/tox.ini b/tox.ini
index f016f20..bf9046a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
1[tox]1[tox]
2envlist = py27, py3, flake8, xenial2envlist = py27, py3, flake8, xenial, pylint
3recreate = True3recreate = True
44
5[testenv]5[testenv]
@@ -17,6 +17,10 @@ commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/}
17setenv =17setenv =
18 LC_ALL = en_US.utf-818 LC_ALL = en_US.utf-8
1919
20[testenv:pylint]
21deps = pylint==1.6.5
22commands = {envpython} -m pylint {posargs:cloudinit}
23
20[testenv:py3]24[testenv:py3]
21basepython = python325basepython = python3
22commands = {envpython} -m nose {posargs:--with-coverage \26commands = {envpython} -m nose {posargs:--with-coverage \
@@ -88,6 +92,10 @@ deps = pycodestyle
88commands = {envpython} -m pyflakes {posargs:cloudinit/ tests/ tools/}92commands = {envpython} -m pyflakes {posargs:cloudinit/ tests/ tools/}
89deps = pyflakes93deps = pyflakes
9094
95[testenv:tip-pylint]
96commands = {envpython} -m pylint {posargs:cloudinit}
97deps = pylint
98
91[testenv:citest]99[testenv:citest]
92basepython = python3100basepython = python3
93commands = {envpython} -m tests.cloud_tests {posargs}101commands = {envpython} -m tests.cloud_tests {posargs}

Subscribers

People subscribed via source and target branches