From ec6afadbf0f0f77d5b58dccd70df77da89c2c91d Mon Sep 17 00:00:00 2001 From: Paride Legovini Date: Tue, 20 Jul 2021 16:58:21 +0200 Subject: Update pylint to v2.9.3 and fix the new issues it spots (#946) In CI run against pylint 2.9.3 and fix occurrences of: - W0237 (arguments-renamed) - W0402 (deprecated-module) The W0402 deprecated-module was about module `imp`: cloudinit/patcher.py:9: [W0402(deprecated-module), ] Uses of a deprecated module 'imp' The imp module is deprecated and replaced by importlib, which according to the documentation has no replacement for acquire_lock() and release_lock(), which are the only reason why `imp` is imported. Nothing about the code using this lock that actually requires it. Let's remove the locking code and the import altogether. Dropping the locking makes patcher.patch() an empty wrapper around _patch_logging(). Rename _patch_logging() to patch_logging() and call it directly instead. Drop patch(). --- cloudinit/distros/opensuse.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cloudinit/distros/opensuse.py') diff --git a/cloudinit/distros/opensuse.py b/cloudinit/distros/opensuse.py index b4193ac2..2a7497cc 100644 --- a/cloudinit/distros/opensuse.py +++ b/cloudinit/distros/opensuse.py @@ -150,9 +150,9 @@ class Distro(distros.Distro): host_fn = self.hostname_conf_fn return (host_fn, self._read_hostname(host_fn)) - def _write_hostname(self, hostname, out_fn): - if self.uses_systemd() and out_fn.endswith('/previous-hostname'): - util.write_file(out_fn, hostname) + def _write_hostname(self, hostname, filename): + if self.uses_systemd() and filename.endswith('/previous-hostname'): + util.write_file(filename, hostname) elif self.uses_systemd(): subp.subp(['hostnamectl', 'set-hostname', str(hostname)]) else: @@ -160,13 +160,13 @@ class Distro(distros.Distro): try: # Try to update the previous one # so lets see if we can read it first. - conf = self._read_hostname_conf(out_fn) + conf = self._read_hostname_conf(filename) except IOError: pass if not conf: conf = HostnameConf('') conf.set_hostname(hostname) - util.write_file(out_fn, str(conf), 0o644) + util.write_file(filename, str(conf), 0o644) @property def preferred_ntp_clients(self): -- cgit v1.2.3