Merge ~smoser/cloud-init:feature/flake8-upgrade into cloud-init:master

Proposed by Scott Moser on 2017-05-23
Status: Merged
Merged at revision: 2825a917e5fa130818c0d77219f32961b99a057f
Proposed branch: ~smoser/cloud-init:feature/flake8-upgrade
Merge into: cloud-init:master
Diff against target: 297 lines (+31/-29)
18 files modified
cloudinit/sources/DataSourceAzure.py (+1/-0)
test-requirements.txt (+4/-4)
tests/unittests/test_datasource/test_altcloud.py (+1/-1)
tests/unittests/test_datasource/test_azure.py (+1/-1)
tests/unittests/test_datasource/test_maas.py (+1/-1)
tests/unittests/test_datasource/test_opennebula.py (+2/-2)
tests/unittests/test_datasource/test_openstack.py (+2/-2)
tests/unittests/test_datasource/test_ovf.py (+1/-1)
tests/unittests/test_distros/test_resolv.py (+1/-1)
tests/unittests/test_handler/test_handler_power_state.py (+2/-2)
tests/unittests/test_handler/test_handler_snappy.py (+2/-2)
tests/unittests/test_helpers.py (+1/-1)
tests/unittests/test_net.py (+1/-1)
tests/unittests/test_util.py (+5/-5)
tools/hacking.py (+3/-2)
tools/mock-meta.py (+1/-1)
tools/net-convert.py (+1/-1)
tox.ini (+1/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2017-05-23
Joshua Powers (community) Approve on 2017-05-23
cloud-init commiters 2017-05-23 Pending
Review via email: mp+324497@code.launchpad.net

Commit Message

flake8: move the pinned version of flake8 up to 3.3.0

This just moves flake8 and related tools up to newer versions and fixes the
complaints associated with that.

We added to the list of flake8 ignores:
 H102: do not put vim info in source files
 H304: no relative imports

To post a comment you must log in.
Scott Moser (smoser) wrote :

I expect :vi info in files (H102)
for H304, I dont have strong feelings. we could fix these.

Scott Moser (smoser) wrote :

for quick reference, H304 shows:
http://paste.ubuntu.com/24635484/

Joshua Powers (powersj) wrote :

LGTM thank you for updating the versions as well.

The tip commands all pass, tox passes, and the versions all look to be good to go.

review: Approve
Scott Moser (smoser) wrote :

Hm..
So after doing this I noticed that pep8 is still in my tox flake8 env and wondered why.

$ pip check
hacking 0.13.0 has requirement flake8<2.6.0,>=2.5.4, but you have flake8 3.3.0.
hacking 0.13.0 has requirement mccabe==0.2.1, but you have mccabe 0.6.1.
hacking 0.13.0 has requirement pyflakes==0.8.1, but you have pyflakes 1.5.0.

I'm not sure of the repercussions of this. It does seem to work.

Scott Moser (smoser) wrote :

https://bugs.launchpad.net/hacking/+bug/1607942
is a 'hacking' upstream bug on versions.

Scott Moser (smoser) wrote :

Given that these are all generally acceptable changes I'm going to pull this. Even if its possible we'd find fallout of the hacking issue.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
2index 44857c0..b9458ff 100644
3--- a/cloudinit/sources/DataSourceAzure.py
4+++ b/cloudinit/sources/DataSourceAzure.py
5@@ -163,6 +163,7 @@ def get_resource_disk_on_freebsd(port_id):
6 return devname
7 return None
8
9+
10 # update the FreeBSD specific information
11 if util.is_FreeBSD():
12 DEFAULT_PRIMARY_NIC = 'hn0'
13diff --git a/test-requirements.txt b/test-requirements.txt
14index 0e7fc8f..1b39ea5 100644
15--- a/test-requirements.txt
16+++ b/test-requirements.txt
17@@ -13,7 +13,7 @@ contextlib2
18 setuptools
19
20 # Used for syle checking
21-pep8==1.7.0
22-pyflakes==1.1.0
23-flake8==2.5.4
24-hacking==0.10.2
25+pycodestyle==2.3.1
26+pyflakes==1.5.0
27+flake8==3.3.0
28+hacking==0.13.0
29diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py
30index 63a2b04..b6d4a45 100644
31--- a/tests/unittests/test_datasource/test_altcloud.py
32+++ b/tests/unittests/test_datasource/test_altcloud.py
33@@ -419,7 +419,7 @@ class TestReadUserDataCallback(TestCase):
34 '''Test read_user_data_callback() no files are found.'''
35
36 _remove_user_data_files(self.mount_dir)
37- self.assertEqual(None, dsac.read_user_data_callback(self.mount_dir))
38+ self.assertIsNone(dsac.read_user_data_callback(self.mount_dir))
39
40
41 def force_arch(arch=None):
42diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
43index 67cddeb..852ec70 100644
44--- a/tests/unittests/test_datasource/test_azure.py
45+++ b/tests/unittests/test_datasource/test_azure.py
46@@ -239,7 +239,7 @@ fdescfs /dev/fd fdescfs rw 0 0
47 with mock.patch.object(os.path, 'exists',
48 return_value=True):
49 res = get_path_dev_freebsd('/etc', mnt_list)
50- self.assertNotEqual(res, None)
51+ self.assertIsNotNone(res)
52
53 def test_basic_seed_dir(self):
54 odata = {'HostName': "myhost", 'UserName': "myuser"}
55diff --git a/tests/unittests/test_datasource/test_maas.py b/tests/unittests/test_datasource/test_maas.py
56index 693882d..c1911bf 100644
57--- a/tests/unittests/test_datasource/test_maas.py
58+++ b/tests/unittests/test_datasource/test_maas.py
59@@ -44,7 +44,7 @@ class TestMAASDataSource(TestCase):
60
61 # verify that 'userdata' is not returned as part of the metadata
62 self.assertFalse(('user-data' in md))
63- self.assertEqual(vd, None)
64+ self.assertIsNone(vd)
65
66 def test_seed_dir_valid_extra(self):
67 """Verify extra files do not affect seed_dir validity."""
68diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
69index bce6612..b0f8e43 100644
70--- a/tests/unittests/test_datasource/test_opennebula.py
71+++ b/tests/unittests/test_datasource/test_opennebula.py
72@@ -126,14 +126,14 @@ class TestOpenNebulaDataSource(TestCase):
73 populate_dir(self.seed_dir, {'context.sh': ''})
74 results = ds.read_context_disk_dir(self.seed_dir)
75
76- self.assertEqual(results['userdata'], None)
77+ self.assertIsNone(results['userdata'])
78 self.assertEqual(results['metadata'], {})
79
80 def test_seed_dir_empty2_context(self):
81 populate_context_dir(self.seed_dir, {})
82 results = ds.read_context_disk_dir(self.seed_dir)
83
84- self.assertEqual(results['userdata'], None)
85+ self.assertIsNone(results['userdata'])
86 self.assertEqual(results['metadata'], {})
87
88 def test_seed_dir_broken_context(self):
89diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py
90index 7bf5508..c2905d1 100644
91--- a/tests/unittests/test_datasource/test_openstack.py
92+++ b/tests/unittests/test_datasource/test_openstack.py
93@@ -242,7 +242,7 @@ class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
94 self.assertEqual(USER_DATA, ds_os.userdata_raw)
95 self.assertEqual(2, len(ds_os.files))
96 self.assertEqual(VENDOR_DATA, ds_os.vendordata_pure)
97- self.assertEqual(ds_os.vendordata_raw, None)
98+ self.assertIsNone(ds_os.vendordata_raw)
99
100 @hp.activate
101 def test_bad_datasource_meta(self):
102@@ -318,7 +318,7 @@ class TestVendorDataLoading(test_helpers.TestCase):
103 self.assertEqual(self.cvj(data), data)
104
105 def test_vd_load_dict_no_ci(self):
106- self.assertEqual(self.cvj({'foo': 'bar'}), None)
107+ self.assertIsNone(self.cvj({'foo': 'bar'}))
108
109 def test_vd_load_dict_ci_dict(self):
110 self.assertRaises(ValueError, self.cvj,
111diff --git a/tests/unittests/test_datasource/test_ovf.py b/tests/unittests/test_datasource/test_ovf.py
112index 3e09510..477cf8e 100644
113--- a/tests/unittests/test_datasource/test_ovf.py
114+++ b/tests/unittests/test_datasource/test_ovf.py
115@@ -68,6 +68,6 @@ class TestReadOvfEnv(test_helpers.TestCase):
116 md, ud, cfg = dsovf.read_ovf_environment(env)
117 self.assertEqual({"instance-id": "inst-001"}, md)
118 self.assertEqual({'password': "passw0rd"}, cfg)
119- self.assertEqual(None, ud)
120+ self.assertIsNone(ud)
121
122 # vi: ts=4 expandtab
123diff --git a/tests/unittests/test_distros/test_resolv.py b/tests/unittests/test_distros/test_resolv.py
124index c9d0347..97168cf 100644
125--- a/tests/unittests/test_distros/test_resolv.py
126+++ b/tests/unittests/test_distros/test_resolv.py
127@@ -30,7 +30,7 @@ class TestResolvHelper(TestCase):
128
129 def test_local_domain(self):
130 rp = resolv_conf.ResolvConf(BASE_RESOLVE)
131- self.assertEqual(None, rp.local_domain)
132+ self.assertIsNone(rp.local_domain)
133
134 rp.local_domain = "bob"
135 self.assertEqual('bob', rp.local_domain)
136diff --git a/tests/unittests/test_handler/test_handler_power_state.py b/tests/unittests/test_handler/test_handler_power_state.py
137index 3fd0069..e382210 100644
138--- a/tests/unittests/test_handler/test_handler_power_state.py
139+++ b/tests/unittests/test_handler/test_handler_power_state.py
140@@ -15,12 +15,12 @@ class TestLoadPowerState(t_help.TestCase):
141 def test_no_config(self):
142 # completely empty config should mean do nothing
143 (cmd, _timeout, _condition) = psc.load_power_state({})
144- self.assertEqual(cmd, None)
145+ self.assertIsNone(cmd)
146
147 def test_irrelevant_config(self):
148 # no power_state field in config should return None for cmd
149 (cmd, _timeout, _condition) = psc.load_power_state({'foo': 'bar'})
150- self.assertEqual(cmd, None)
151+ self.assertIsNone(cmd)
152
153 def test_invalid_mode(self):
154 cfg = {'power_state': {'mode': 'gibberish'}}
155diff --git a/tests/unittests/test_handler/test_handler_snappy.py b/tests/unittests/test_handler/test_handler_snappy.py
156index edb73d6..e4d0762 100644
157--- a/tests/unittests/test_handler/test_handler_snappy.py
158+++ b/tests/unittests/test_handler/test_handler_snappy.py
159@@ -419,7 +419,7 @@ class TestSnapConfig(FilesystemMockingTestCase):
160
161 def test_snap_config_add_snap_user_no_config(self):
162 usercfg = add_snap_user(cfg=None)
163- self.assertEqual(usercfg, None)
164+ self.assertIsNone(usercfg)
165
166 def test_snap_config_add_snap_user_not_dict(self):
167 cfg = ['foobar']
168@@ -428,7 +428,7 @@ class TestSnapConfig(FilesystemMockingTestCase):
169 def test_snap_config_add_snap_user_no_email(self):
170 cfg = {'assertions': [], 'known': True}
171 usercfg = add_snap_user(cfg=cfg)
172- self.assertEqual(usercfg, None)
173+ self.assertIsNone(usercfg)
174
175 @mock.patch('cloudinit.config.cc_snap_config.util')
176 def test_snap_config_add_snap_user_email_only(self, mock_util):
177diff --git a/tests/unittests/test_helpers.py b/tests/unittests/test_helpers.py
178index 955f8df..f1979e8 100644
179--- a/tests/unittests/test_helpers.py
180+++ b/tests/unittests/test_helpers.py
181@@ -32,6 +32,6 @@ class TestPaths(test_helpers.ResourceUsingTestCase):
182 myds._instance_id = None
183 mypaths = self.getCloudPaths(myds)
184
185- self.assertEqual(None, mypaths.get_ipath())
186+ self.assertIsNone(mypaths.get_ipath())
187
188 # vi: ts=4 expandtab
189diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
190index feeab90..7104d00 100644
191--- a/tests/unittests/test_net.py
192+++ b/tests/unittests/test_net.py
193@@ -1301,7 +1301,7 @@ class TestCmdlineReadKernelConfig(CiTestCase):
194 files = sorted(populate_dir(self.tmp_dir(), content))
195 found = cmdline.read_kernel_cmdline_config(
196 files=files, cmdline='foo root=/dev/sda', mac_addrs=self.macs)
197- self.assertEqual(found, None)
198+ self.assertIsNone(found)
199
200 def test_ip_cmdline_both_ip_ip6(self):
201 content = {'net-eth0.conf': DHCP_CONTENT_1,
202diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
203index 490760d..014aa6a 100644
204--- a/tests/unittests/test_util.py
205+++ b/tests/unittests/test_util.py
206@@ -44,7 +44,7 @@ class TestGetCfgOptionListOrStr(helpers.TestCase):
207 """None is returned if key is not found and no default given."""
208 config = {}
209 result = util.get_cfg_option_list(config, "key")
210- self.assertEqual(None, result)
211+ self.assertIsNone(result)
212
213 def test_not_found_with_default(self):
214 """Default is returned if key is not found."""
215@@ -432,13 +432,13 @@ class TestReadDMIData(helpers.FilesystemMockingTestCase):
216 def test_none_returned_if_neither_source_has_data(self):
217 self.patch_mapping({})
218 self._configure_dmidecode_return('key', 'value')
219- self.assertEqual(None, util.read_dmi_data('expect-fail'))
220+ self.assertIsNone(util.read_dmi_data('expect-fail'))
221
222 def test_none_returned_if_dmidecode_not_in_path(self):
223 self.patched_funcs.enter_context(
224 mock.patch.object(util, 'which', lambda _: False))
225 self.patch_mapping({})
226- self.assertEqual(None, util.read_dmi_data('expect-fail'))
227+ self.assertIsNone(util.read_dmi_data('expect-fail'))
228
229 def test_dots_returned_instead_of_foxfox(self):
230 # uninitialized dmi values show as \xff, return those as .
231@@ -626,8 +626,8 @@ class TestSubp(helpers.TestCase):
232
233 def test_returns_none_if_no_capture(self):
234 (out, err) = util.subp(self.stdin2out, data=b'', capture=False)
235- self.assertEqual(err, None)
236- self.assertEqual(out, None)
237+ self.assertIsNone(err)
238+ self.assertIsNone(out)
239
240 def test_bunch_of_slashes_in_path(self):
241 self.assertEqual("/target/my/path/",
242diff --git a/tools/hacking.py b/tools/hacking.py
243index 6c32093..e6a0513 100755
244--- a/tools/hacking.py
245+++ b/tools/hacking.py
246@@ -165,7 +165,8 @@ if __name__ == "__main__":
247 pep8._main()
248 finally:
249 if len(_missingImport) > 0:
250- print >> sys.stderr, ("%i imports missing in this test environment"
251- % len(_missingImport))
252+ sys.stderr.write(
253+ "%i imports missing in this test environment\n" %
254+ len(_missingImport))
255
256 # vi: ts=4 expandtab
257diff --git a/tools/mock-meta.py b/tools/mock-meta.py
258index 82816e8..f185dbf 100755
259--- a/tools/mock-meta.py
260+++ b/tools/mock-meta.py
261@@ -21,8 +21,8 @@ import functools
262 import json
263 import logging
264 import os
265-import socket
266 import random
267+import socket
268 import string
269 import sys
270 import yaml
271diff --git a/tools/net-convert.py b/tools/net-convert.py
272index 870da63..b2db8ad 100755
273--- a/tools/net-convert.py
274+++ b/tools/net-convert.py
275@@ -9,8 +9,8 @@ import yaml
276 from cloudinit.sources.helpers import openstack
277
278 from cloudinit.net import eni
279-from cloudinit.net import network_state
280 from cloudinit.net import netplan
281+from cloudinit.net import network_state
282 from cloudinit.net import sysconfig
283
284
285diff --git a/tox.ini b/tox.ini
286index fce0774..03bb5f1 100644
287--- a/tox.ini
288+++ b/tox.ini
289@@ -34,7 +34,7 @@ setenv =
290
291 [flake8]
292 #H102 Apache 2.0 license header not found
293-ignore=H404,H405,H105,H301,H104,H403,H101,H102
294+ignore=H404,H405,H105,H301,H104,H403,H101,H102,H106,H304
295 exclude = .venv,.tox,dist,doc,*egg,.git,build,tools
296
297 [testenv:doc]

Subscribers

People subscribed via source and target branches

to all changes: