From 61d794f1711c01ed4c462e5d4dff693682fb21ad Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 31 Dec 2025 11:27:49 +1300 Subject: [PATCH] incus conn plugin: improve readability (was ruff: set target-python 3.7) (#11346) * incus connection plugin: improve readability * add changelog frag * Update plugins/connection/incus.py Co-authored-by: Felix Fontein * Update plugins/connection/incus.py * Update plugins/connection/incus.py Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/11346-incus-readability.yml | 2 ++ plugins/connection/incus.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/11346-incus-readability.yml diff --git a/changelogs/fragments/11346-incus-readability.yml b/changelogs/fragments/11346-incus-readability.yml new file mode 100644 index 0000000000..9a8e770601 --- /dev/null +++ b/changelogs/fragments/11346-incus-readability.yml @@ -0,0 +1,2 @@ +minor_changes: + - incus connection plugin - improve code readability (https://github.com/ansible-collections/community.general/pull/11346). diff --git a/plugins/connection/incus.py b/plugins/connection/incus.py index bab0e1b6f8..fe0c577296 100644 --- a/plugins/connection/incus.py +++ b/plugins/connection/incus.py @@ -142,10 +142,12 @@ class Connection(ConnectionBase): ] if getattr(self._shell, "_IS_WINDOWS", False): - if ( - (regex_match := self.powershell_regex_pattern.match(cmd)) - and (regex_pattern := self.powershell_regex_pattern) - ) or ((regex_match := self.cmd_regex_pattern.match(cmd)) and (regex_pattern := self.cmd_regex_pattern)): + if regex_match := self.powershell_regex_pattern.match(cmd): + regex_pattern = self.powershell_regex_pattern + elif regex_match := self.cmd_regex_pattern.match(cmd): + regex_pattern = self.cmd_regex_pattern + + if regex_match: self._display.vvvvvv( f'Found keyword: "{regex_match.group("command")}" based on regex: {regex_pattern.pattern}', host=self._instance(),