diff options
author | Paride Legovini <paride.legovini@canonical.com> | 2021-07-20 16:58:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 09:58:21 -0500 |
commit | ec6afadbf0f0f77d5b58dccd70df77da89c2c91d (patch) | |
tree | 5f1a719faf924b28cdc2d6958a3b6a8eb2c771bf /cloudinit/patcher.py | |
parent | a984ee78b745b157b4b023a1786bfbd3b2002b88 (diff) | |
download | vyos-cloud-init-ec6afadbf0f0f77d5b58dccd70df77da89c2c91d.tar.gz vyos-cloud-init-ec6afadbf0f0f77d5b58dccd70df77da89c2c91d.zip |
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().
Diffstat (limited to 'cloudinit/patcher.py')
-rw-r--r-- | cloudinit/patcher.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/cloudinit/patcher.py b/cloudinit/patcher.py index 2df9441a..186d8ad8 100644 --- a/cloudinit/patcher.py +++ b/cloudinit/patcher.py @@ -6,7 +6,6 @@ # # This file is part of cloud-init. See LICENSE file for license information. -import imp import logging import sys @@ -20,7 +19,7 @@ class QuietStreamHandler(logging.StreamHandler): pass -def _patch_logging(): +def patch_logging(): # Replace 'handleError' with one that will be more # tolerant of errors in that it can avoid # re-notifying on exceptions and when errors @@ -37,12 +36,4 @@ def _patch_logging(): pass setattr(logging.Handler, 'handleError', handleError) - -def patch(): - imp.acquire_lock() - try: - _patch_logging() - finally: - imp.release_lock() - # vi: ts=4 expandtab |