Skip to content

Commit 4620f16

Browse files
committed
cloudinit: minor pylint fixes
We recently discovered that pylint is failing to report some errors when invoked across our entire codebase (see pylint-dev/pylint#3611). I've run pylint across every Python file under cloudinit/[0], and this commit fixes the issues so-discovered. [0] find cloudinit/ -name "*.py" | xargs -n 1 -t .tox/pylint/bin/python -m pylint
1 parent f9d0414 commit 4620f16

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

cloudinit/config/tests/test_snap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def test_schema_when_assertions_are_list_or_dict(self, _):
345345
def test_duplicates_are_fine_array_array(self):
346346
"""Duplicated commands array/array entries are allowed."""
347347
self.assertSchemaValid(
348-
{'commands': [["echo", "bye"], ["echo" "bye"]]},
348+
{'commands': [["echo", "bye"], ["echo", "bye"]]},
349349
"command entries can be duplicate.")
350350

351351
def test_duplicates_are_fine_array_string(self):

cloudinit/config/tests/test_ubuntu_drivers.py

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
"(choose from 'list', 'autoinstall', 'devices', 'debug')\n")
1717

1818

19+
# The tests in this module call helper methods which are decorated with
20+
# mock.patch. pylint doesn't understand that mock.patch passes in parameters
21+
# to the decorated function, so it incorrectly reports that we aren't passing
22+
# values for all parameters. Instead of annotating every single call, we
23+
# disable it for the entire module:
24+
# pylint: disable=no-value-for-parameter
25+
1926
class AnyTempScriptAndDebconfFile(object):
2027

2128
def __init__(self, tmp_dir, debconf_file):

cloudinit/sources/helpers/tests/test_netlink.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_read_none_data(self):
8787
data = None
8888
with self.assertRaises(AssertionError) as context:
8989
read_rta_oper_state(data)
90-
self.assertTrue('data is none', str(context.exception))
90+
self.assertEqual('data is none', str(context.exception))
9191

9292
def test_read_invalid_rta_operstate_none(self):
9393
'''read_rta_oper_state returns none if operstate is none'''

cloudinit/tests/test_conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def test_using_subp_raises_assertion_error(self):
1111

1212
def test_typeerrors_on_incorrect_usage(self):
1313
with pytest.raises(TypeError):
14+
# We are intentionally passing no value for a parameter, so:
15+
# pylint: disable=no-value-for-parameter
1416
util.subp()
1517

1618
@pytest.mark.parametrize('disable_subp_usage', [False], indirect=True)

0 commit comments

Comments
 (0)