From ac6c6df2c7666bafecd3f4c0769bb71e5ecce226 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 21:31:22 +0100 Subject: [PATCH] [PR #11121/c45fba54 backport][stable-12] fix ruff case E721 (#11133) fix ruff case E721 (#11121) * fix ruff case E721 * add changelog frag (cherry picked from commit c45fba549f04337726b7b380968f307a72e527ff) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/11121-ruff-cases-3.yml | 2 ++ plugins/modules/nmcli.py | 4 ++-- ruff.toml | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/11121-ruff-cases-3.yml diff --git a/changelogs/fragments/11121-ruff-cases-3.yml b/changelogs/fragments/11121-ruff-cases-3.yml new file mode 100644 index 0000000000..e5316cd102 --- /dev/null +++ b/changelogs/fragments/11121-ruff-cases-3.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - fix comparison of type (https://github.com/ansible-collections/community.general/pull/11121). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 58519578c5..265427daf3 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -2489,7 +2489,7 @@ class Nmcli: if key and len(pair) > 1: raw_value = pair[1].lstrip() if raw_value == "--": - if key_type == list: + if key_type is list: conn_info[key] = [] else: conn_info[key] = None @@ -2504,7 +2504,7 @@ class Nmcli: conn_info[alias_key] = alias_value elif key in ("ipv4.routes", "ipv6.routes"): conn_info[key] = [s.strip() for s in raw_value.split(";")] - elif key_type == list: + elif key_type is list: conn_info[key] = [s.strip() for s in raw_value.split(",")] else: m_enum = p_enum_value.match(raw_value) diff --git a/ruff.toml b/ruff.toml index 046c1f7e98..693108f57c 100644 --- a/ruff.toml +++ b/ruff.toml @@ -21,7 +21,6 @@ ignore = [ "B905", # zip-without-explicit-strict - needs Python 3.10+ "UP045", # Use `X | None` for type annotations - needs Python 3.10+ # To fix: - "E721", # Type comparison "UP014", # Convert `xxx` from `NamedTuple` functional to class syntax "UP024", # Replace aliased errors with `OSError` "UP028", # Replace `yield` over `for` loop with `yield from`