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(),