Python code modernization, 4/n (#1162)

* Address attribute-defined-outside-init.

* Address broad-exception-raised.

* Address broad-exception-caught.

* Address consider-iterating-dictionary.

* Address consider-using-dict-comprehension.

* Address consider-using-f-string.

* Address consider-using-in.

* Address consider-using-max-builtin.

* Address some consider-using-with.

* Address invalid-name.

* Address keyword-arg-before-vararg.

* Address line-too-long.

* Address no-else-continue.

* Address no-else-raise.

* Address no-else-return.

* Remove broken dead code.

* Make consider-using-f-string changes compatible with older Python versions.

* Python 3.11 and earlier apparently do not like multi-line f-strings.
This commit is contained in:
Felix Fontein
2025-10-11 23:06:50 +02:00
committed by GitHub
parent 33c8a49191
commit cad22de628
59 changed files with 556 additions and 630 deletions
+1 -3
View File
@@ -40,6 +40,4 @@ class AnsibleDockerClient(AnsibleDockerClientBase):
)
def _get_params(self):
return dict(
[(option, self.plugin.get_option(option)) for option in DOCKER_COMMON_ARGS]
)
return {option: self.plugin.get_option(option) for option in DOCKER_COMMON_ARGS}
+1 -3
View File
@@ -37,6 +37,4 @@ class AnsibleDockerClient(AnsibleDockerClientBase):
)
def _get_params(self):
return dict(
[(option, self.plugin.get_option(option)) for option in DOCKER_COMMON_ARGS]
)
return {option: self.plugin.get_option(option) for option in DOCKER_COMMON_ARGS}
+4 -4
View File
@@ -27,15 +27,15 @@ def make_unsafe(value):
if isinstance(value, Mapping):
return dict((make_unsafe(key), make_unsafe(val)) for key, val in value.items())
elif isinstance(value, Set):
if isinstance(value, Set):
return set(make_unsafe(elt) for elt in value)
elif is_sequence(value):
if is_sequence(value):
return type(value)(make_unsafe(elt) for elt in value)
elif isinstance(value, bytes):
if isinstance(value, bytes):
if _RE_TEMPLATE_CHARS_BYTES.search(value):
value = _make_unsafe(value)
return value
elif isinstance(value, str):
if isinstance(value, str):
if _RE_TEMPLATE_CHARS.search(value):
value = _make_unsafe(value)
return value