Skip to content

Commit

Permalink
Update pylint version to support python 3.12 (#5338)
Browse files Browse the repository at this point in the history
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:
pylint-dev/pylint#8782

Minimum version of pylint required in order to support python 3.12 is 3.0.2.
Please see pylint-dev/astroid#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>
  • Loading branch information
ani-sinha authored and holmanb committed Jun 28, 2024
1 parent 63e26ec commit 55ecf3b
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions cloudinit/config/cc_mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def create_swap(fname, size, method):
"bs=1M",
"count=%s" % size,
]
else:
raise subp.ProcessExecutionError(
"Missing dependency: 'dd' and 'fallocate' are not available"
)

try:
subp.subp(cmd, capture=True)
Expand Down
2 changes: 2 additions & 0 deletions cloudinit/distros/bsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def package_command(self, command, args=None, pkgs=None):
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)
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/distros/netbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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(
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/sources/DataSourceAzure.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
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)}"
Expand Down
3 changes: 2 additions & 1 deletion cloudinit/sources/DataSourceEc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def _maybe_fetch_api_token(self, mdurls):
return None

def wait_for_metadata_service(self):
urls = []
start_time = 0
mcfg = self.ds_cfg

url_params = self.get_url_params()
Expand Down Expand Up @@ -369,7 +371,6 @@ def wait_for_metadata_service(self):
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
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/sources/DataSourceLXD.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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:
Expand Down
1 change: 1 addition & 0 deletions cloudinit/sources/DataSourceWSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def _get_data(self) -> bool:
return False

seed_dir = cloud_init_data_dir(user_home)
agent_data = None
user_data: Optional[Union[dict, bytes]] = None

# Load any metadata
Expand Down
1 change: 0 additions & 1 deletion cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,6 @@ class Version(namedtuple("Version", ["major", "minor", "patch", "rev"])):
:raises ValueError: If invalid arguments are given.
Examples:
>>> Version(2, 9) == Version.from_str("2.9")
True
>>> Version(2, 9, 1) > Version.from_str("2.9.1")
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,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."""
Expand All @@ -327,7 +327,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."""
Expand All @@ -336,7 +336,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."""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,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

Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/config/test_cc_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def test_distro_ntp_client_configs(self):
)

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
Expand All @@ -264,6 +265,7 @@ def _get_expected_pools(self, pools, distro, client):
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
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/sources/test_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _set_mock_metadata(self, gce_meta=None, *, check_headers=None):
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]
Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,8 @@ def preexec_fn(self, request):
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)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.3
types-jsonschema==4.4.2
Expand Down

0 comments on commit 55ecf3b

Please sign in to comment.