Skip to content

Commit

Permalink
cloudinit: minor pylint fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
OddBloke committed May 11, 2020
1 parent f9d0414 commit 4620f16
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cloudinit/config/tests/test_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_schema_when_assertions_are_list_or_dict(self, _):
def test_duplicates_are_fine_array_array(self):
"""Duplicated commands array/array entries are allowed."""
self.assertSchemaValid(
{'commands': [["echo", "bye"], ["echo" "bye"]]},
{'commands': [["echo", "bye"], ["echo", "bye"]]},
"command entries can be duplicate.")

def test_duplicates_are_fine_array_string(self):
Expand Down
7 changes: 7 additions & 0 deletions cloudinit/config/tests/test_ubuntu_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"(choose from 'list', 'autoinstall', 'devices', 'debug')\n")


# The tests in this module call helper methods which are decorated with
# mock.patch. pylint doesn't understand that mock.patch passes in parameters
# to the decorated function, so it incorrectly reports that we aren't passing
# values for all parameters. Instead of annotating every single call, we
# disable it for the entire module:
# pylint: disable=no-value-for-parameter

class AnyTempScriptAndDebconfFile(object):

def __init__(self, tmp_dir, debconf_file):
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/sources/helpers/tests/test_netlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_read_none_data(self):
data = None
with self.assertRaises(AssertionError) as context:
read_rta_oper_state(data)
self.assertTrue('data is none', str(context.exception))
self.assertEqual('data is none', str(context.exception))

def test_read_invalid_rta_operstate_none(self):
'''read_rta_oper_state returns none if operstate is none'''
Expand Down
2 changes: 2 additions & 0 deletions cloudinit/tests/test_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def test_using_subp_raises_assertion_error(self):

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

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

0 comments on commit 4620f16

Please sign in to comment.