f1f4c0a890
- ci-feat-sysconfig-Add-DNS-from-interface-config-to-reso.patch [RHEL-17961] - ci-fix-jsonschema-Add-missing-sudo-definition-5418.patch [RHEL-44337] - ci-doc-update-examples-to-reflect-alternative-ways-to-p.patch [RHEL-44337] - ci-fix-dhcp-Guard-against-FileNotFoundError-and-NameErr.patch [RHEL-44598] - ci-fix-Address-TIOBE-abstract-interpretation-issues-486.patch [RHEL-44598] - ci-Update-pylint-version-to-support-python-3.12-5338.patch [RHEL-44598] - Resolves: RHEL-17961 ([RHEL-9] cloud-init fails to configure DNS search domains) - Resolves: RHEL-44337 ([rhel-9] fix `SUDO` configuration schema for users and groups) - Resolves: RHEL-44598 (fix pylint error and support python 3.12)
236 lines
8.7 KiB
Diff
236 lines
8.7 KiB
Diff
From c34f5c4275c3ef7bee9a99e87bf6e37c5886b160 Mon Sep 17 00:00:00 2001
|
|
From: Ani Sinha <anisinha@redhat.com>
|
|
Date: Wed, 29 May 2024 03:34:38 +0530
|
|
Subject: [PATCH 6/6] Update pylint version to support python 3.12 (#5338)
|
|
|
|
RH-Author: Ani Sinha <anisinha@redhat.com>
|
|
RH-MergeRequest: 92: Update pylint version to support python 3.12
|
|
RH-Jira: RHEL-44598
|
|
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
RH-Commit: [3/3] d6185e0a126e1589260ee59709fe933b5a780b78 (anisinha/cloud-init)
|
|
|
|
Fedora 39 and above comes with python version 3.12. When running `tox -e pylint`
|
|
on cloud-init, we may experience issue such as the one reported here:
|
|
https://github.com/pylint-dev/pylint/issues/8782
|
|
|
|
Minimum version of pylint required in order to support python 3.12 is 3.0.2.
|
|
Please see https://github.com/pylint-dev/astroid/issues/2201 . Upon further
|
|
experimentation, it is seen that we need minimum pylint version 3.2.0 for
|
|
cloud-init. Update tox.ini in order to use this pylint version.
|
|
|
|
Signed-off-by: Ani Sinha <anisinha@redhat.com>
|
|
(cherry picked from commit 5ad609ffdf4bb76c5665e12e34e1867b72bd4435)
|
|
|
|
Conflicts:
|
|
cloudinit/sources/DataSourceWSL.py (does not exist)
|
|
cloudinit/util.py (doc added upstream)
|
|
---
|
|
cloudinit/config/cc_mounts.py | 4 ++++
|
|
cloudinit/distros/bsd.py | 2 ++
|
|
cloudinit/distros/netbsd.py | 2 +-
|
|
cloudinit/sources/DataSourceAzure.py | 2 +-
|
|
cloudinit/sources/DataSourceEc2.py | 3 ++-
|
|
cloudinit/sources/DataSourceLXD.py | 2 +-
|
|
tests/integration_tests/conftest.py | 6 +++---
|
|
tests/integration_tests/util.py | 2 +-
|
|
tests/unittests/config/test_cc_ntp.py | 2 ++
|
|
tests/unittests/sources/test_gce.py | 1 +
|
|
tests/unittests/test_util.py | 2 ++
|
|
tox.ini | 2 +-
|
|
12 files changed, 21 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
|
|
index 4efa2a29..d445b440 100644
|
|
--- a/cloudinit/config/cc_mounts.py
|
|
+++ b/cloudinit/config/cc_mounts.py
|
|
@@ -304,6 +304,10 @@ def create_swapfile(fname: str, size: str) -> None:
|
|
"bs=1M",
|
|
"count=%s" % size,
|
|
]
|
|
+ else:
|
|
+ raise subp.ProcessExecutionError(
|
|
+ "Missing dependency: 'dd' and 'fallocate' are not available"
|
|
+ )
|
|
|
|
try:
|
|
subp.subp(cmd, capture=True)
|
|
diff --git a/cloudinit/distros/bsd.py b/cloudinit/distros/bsd.py
|
|
index 761cf5c4..77e0385f 100644
|
|
--- a/cloudinit/distros/bsd.py
|
|
+++ b/cloudinit/distros/bsd.py
|
|
@@ -120,6 +120,8 @@ class BSD(distros.Distro):
|
|
if not self.pkg_cmd_upgrade_prefix:
|
|
return
|
|
cmd = self.pkg_cmd_upgrade_prefix
|
|
+ else:
|
|
+ cmd = []
|
|
|
|
if args and isinstance(args, str):
|
|
cmd.append(args)
|
|
diff --git a/cloudinit/distros/netbsd.py b/cloudinit/distros/netbsd.py
|
|
index a5678907..b7f3f3d8 100644
|
|
--- a/cloudinit/distros/netbsd.py
|
|
+++ b/cloudinit/distros/netbsd.py
|
|
@@ -12,7 +12,7 @@ import cloudinit.distros.bsd
|
|
from cloudinit import subp, util
|
|
|
|
try:
|
|
- import crypt
|
|
+ import crypt # pylint: disable=W4901
|
|
|
|
salt = crypt.METHOD_BLOWFISH # pylint: disable=E1101
|
|
blowfish_hash: Any = functools.partial(
|
|
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
|
|
index 11c14e20..eb0304c3 100644
|
|
--- a/cloudinit/sources/DataSourceAzure.py
|
|
+++ b/cloudinit/sources/DataSourceAzure.py
|
|
@@ -51,7 +51,7 @@ from cloudinit.sources.helpers.azure import (
|
|
from cloudinit.url_helper import UrlError
|
|
|
|
try:
|
|
- import crypt
|
|
+ import crypt # pylint: disable=W4901
|
|
|
|
blowfish_hash: Any = functools.partial(
|
|
crypt.crypt, salt=f"$6${util.rand_str(strlen=16)}"
|
|
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
|
|
index 9e6bfbd1..384e4074 100644
|
|
--- a/cloudinit/sources/DataSourceEc2.py
|
|
+++ b/cloudinit/sources/DataSourceEc2.py
|
|
@@ -312,6 +312,8 @@ class DataSourceEc2(sources.DataSource):
|
|
return None
|
|
|
|
def wait_for_metadata_service(self):
|
|
+ urls = []
|
|
+ start_time = 0
|
|
mcfg = self.ds_cfg
|
|
|
|
url_params = self.get_url_params()
|
|
@@ -345,7 +347,6 @@ class DataSourceEc2(sources.DataSource):
|
|
and self.cloud_name not in IDMSV2_SUPPORTED_CLOUD_PLATFORMS
|
|
):
|
|
# if we can't get a token, use instance-id path
|
|
- urls = []
|
|
url2base = {}
|
|
url_path = "{ver}/meta-data/instance-id".format(
|
|
ver=self.min_metadata_version
|
|
diff --git a/cloudinit/sources/DataSourceLXD.py b/cloudinit/sources/DataSourceLXD.py
|
|
index cd316101..4c95b907 100644
|
|
--- a/cloudinit/sources/DataSourceLXD.py
|
|
+++ b/cloudinit/sources/DataSourceLXD.py
|
|
@@ -331,7 +331,7 @@ class MetaDataKeys(Flag):
|
|
CONFIG = auto()
|
|
DEVICES = auto()
|
|
META_DATA = auto()
|
|
- ALL = CONFIG | DEVICES | META_DATA
|
|
+ ALL = CONFIG | DEVICES | META_DATA # pylint: disable=E1131
|
|
|
|
|
|
class _MetaDataReader:
|
|
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py
|
|
index fa729b7d..ec211a00 100644
|
|
--- a/tests/integration_tests/conftest.py
|
|
+++ b/tests/integration_tests/conftest.py
|
|
@@ -241,7 +241,7 @@ def _client(
|
|
|
|
|
|
@pytest.fixture
|
|
-def client(
|
|
+def client( # pylint: disable=W0135
|
|
request, fixture_utils, session_cloud, setup_image
|
|
) -> Iterator[IntegrationInstance]:
|
|
"""Provide a client that runs for every test."""
|
|
@@ -250,7 +250,7 @@ def client(
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
-def module_client(
|
|
+def module_client( # pylint: disable=W0135
|
|
request, fixture_utils, session_cloud, setup_image
|
|
) -> Iterator[IntegrationInstance]:
|
|
"""Provide a client that runs once per module."""
|
|
@@ -259,7 +259,7 @@ def module_client(
|
|
|
|
|
|
@pytest.fixture(scope="class")
|
|
-def class_client(
|
|
+def class_client( # pylint: disable=W0135
|
|
request, fixture_utils, session_cloud, setup_image
|
|
) -> Iterator[IntegrationInstance]:
|
|
"""Provide a client that runs once per class."""
|
|
diff --git a/tests/integration_tests/util.py b/tests/integration_tests/util.py
|
|
index 0a15203c..e26e466c 100644
|
|
--- a/tests/integration_tests/util.py
|
|
+++ b/tests/integration_tests/util.py
|
|
@@ -182,7 +182,7 @@ def wait_for_cloud_init(client: IntegrationInstance, num_retries: int = 30):
|
|
except Exception as e:
|
|
last_exception = e
|
|
time.sleep(1)
|
|
- raise Exception(
|
|
+ raise Exception( # pylint: disable=W0719
|
|
"cloud-init status did not return successfully."
|
|
) from last_exception
|
|
|
|
diff --git a/tests/unittests/config/test_cc_ntp.py b/tests/unittests/config/test_cc_ntp.py
|
|
index a9444ec5..c9ce5daa 100644
|
|
--- a/tests/unittests/config/test_cc_ntp.py
|
|
+++ b/tests/unittests/config/test_cc_ntp.py
|
|
@@ -248,6 +248,7 @@ class TestNtp(FilesystemMockingTestCase):
|
|
)
|
|
|
|
def _get_expected_pools(self, pools, distro, client):
|
|
+ expected_pools = None
|
|
if client in ["ntp", "chrony"]:
|
|
if client == "ntp" and distro == "alpine":
|
|
# NTP for Alpine Linux is Busybox's ntp which does not
|
|
@@ -263,6 +264,7 @@ class TestNtp(FilesystemMockingTestCase):
|
|
return expected_pools
|
|
|
|
def _get_expected_servers(self, servers, distro, client):
|
|
+ expected_servers = None
|
|
if client in ["ntp", "chrony"]:
|
|
if client == "ntp" and distro == "alpine":
|
|
# NTP for Alpine Linux is Busybox's ntp which only supports
|
|
diff --git a/tests/unittests/sources/test_gce.py b/tests/unittests/sources/test_gce.py
|
|
index c0b19d3c..30a50236 100644
|
|
--- a/tests/unittests/sources/test_gce.py
|
|
+++ b/tests/unittests/sources/test_gce.py
|
|
@@ -101,6 +101,7 @@ class TestDataSourceGCE(test_helpers.ResponsesTestCase):
|
|
gce_meta = GCE_META
|
|
|
|
def _request_callback(request):
|
|
+ recursive = False
|
|
url_path = urlparse(request.url).path
|
|
if url_path.startswith("/computeMetadata/v1/"):
|
|
path = url_path.split("/computeMetadata/v1/")[1:][0]
|
|
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
|
|
index 519ef63c..de1326d4 100644
|
|
--- a/tests/unittests/test_util.py
|
|
+++ b/tests/unittests/test_util.py
|
|
@@ -1677,6 +1677,8 @@ class TestRedirectOutputPreexecFn:
|
|
args = (test_string, None)
|
|
elif request.param == "errfmt":
|
|
args = (None, test_string)
|
|
+ else:
|
|
+ args = (None, None)
|
|
with mock.patch(M_PATH + "subprocess.Popen") as m_popen:
|
|
util.redirect_output(*args)
|
|
|
|
diff --git a/tox.ini b/tox.ini
|
|
index 5f01a9a8..5199ca13 100644
|
|
--- a/tox.ini
|
|
+++ b/tox.ini
|
|
@@ -25,7 +25,7 @@ hypothesis==6.31.6
|
|
hypothesis_jsonschema==0.20.1
|
|
isort==5.10.1
|
|
mypy==0.950
|
|
-pylint==2.13.9
|
|
+pylint==3.2.0
|
|
pytest==7.0.1
|
|
ruff==0.0.285
|
|
types-jsonschema==4.4.2
|
|
--
|
|
2.39.3
|
|
|