diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-05-14 15:39:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 15:39:19 -0400 |
commit | 09492b1d0f4b1826a7a98709c61d48bf14a1ec64 (patch) | |
tree | 9150f282f7925c331235d1bb7199ba5b778c146e /cloudinit | |
parent | 4261ae538563d262bc76b8c55f7cc0c8abb14b00 (diff) | |
download | vyos-cloud-init-09492b1d0f4b1826a7a98709c61d48bf14a1ec64.tar.gz vyos-cloud-init-09492b1d0f4b1826a7a98709c61d48bf14a1ec64.zip |
cloudinit: minor pylint fixes (#360)
We recently discovered that pylint is failing to report some errors when
invoked across our entire codebase (see
https://github.com/PyCQA/pylint/issues/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
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/tests/test_snap.py | 2 | ||||
-rw-r--r-- | cloudinit/config/tests/test_ubuntu_drivers.py | 7 | ||||
-rw-r--r-- | cloudinit/sources/helpers/tests/test_netlink.py | 2 | ||||
-rw-r--r-- | cloudinit/tests/test_conftest.py | 2 |
4 files changed, 11 insertions, 2 deletions
diff --git a/cloudinit/config/tests/test_snap.py b/cloudinit/config/tests/test_snap.py index cbbb173d..70676942 100644 --- a/cloudinit/config/tests/test_snap.py +++ b/cloudinit/config/tests/test_snap.py @@ -345,7 +345,7 @@ class TestSchema(CiTestCase, SchemaTestCaseMixin): 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): diff --git a/cloudinit/config/tests/test_ubuntu_drivers.py b/cloudinit/config/tests/test_ubuntu_drivers.py index 46952692..0aec1265 100644 --- a/cloudinit/config/tests/test_ubuntu_drivers.py +++ b/cloudinit/config/tests/test_ubuntu_drivers.py @@ -16,6 +16,13 @@ OLD_UBUNTU_DRIVERS_ERROR_STDERR = ( "(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 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): diff --git a/cloudinit/sources/helpers/tests/test_netlink.py b/cloudinit/sources/helpers/tests/test_netlink.py index c2898a16..58c3adc6 100644 --- a/cloudinit/sources/helpers/tests/test_netlink.py +++ b/cloudinit/sources/helpers/tests/test_netlink.py @@ -87,7 +87,7 @@ class TestParseNetlinkMessage(CiTestCase): 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''' diff --git a/cloudinit/tests/test_conftest.py b/cloudinit/tests/test_conftest.py index 11b91327..b39637d8 100644 --- a/cloudinit/tests/test_conftest.py +++ b/cloudinit/tests/test_conftest.py @@ -13,6 +13,8 @@ class TestDisableSubpUsage: 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) |