1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

[PR #11189/1c678f5c backport][stable-12] fix ruff case UP030 (#11195)

fix ruff case UP030 (#11189)

* fix ruff case UP030

* add changelog frag

* formatting

* suggestion from review

(cherry picked from commit 1c678f5c07)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2025-11-23 08:58:57 +01:00 committed by GitHub
parent 084ecd96e1
commit f648dca84a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 10 deletions

View file

@ -0,0 +1,4 @@
minor_changes:
- dependent lookup plugin - improve templating of strings (https://github.com/ansible-collections/community.general/pull/11189).
- oci_utils module utils - improve templating of strings (https://github.com/ansible-collections/community.general/pull/11189).
- snap - improve templating of strings (https://github.com/ansible-collections/community.general/pull/11189).

View file

@ -145,7 +145,9 @@ class LookupModule(LookupBase):
``variables`` are the variables to use.
"""
templar.available_variables = variables or {}
quoted_expression = "{0}{1}{2}".format("{{", expression, "}}")
open_br = "{{"
close_br = "}}"
quoted_expression = f"{open_br}{expression}{close_br}"
if hasattr(templar, "evaluate_expression"):
# This is available since the Data Tagging PR has been merged
return templar.evaluate_expression(_make_safe(expression))

View file

@ -231,12 +231,12 @@ def get_oci_config(module, service_client_class=None):
"OCI_IDENTITY_DO_NOT_REDIRECT_TO_HOME_REGION"
)
if service_client_class == IdentityClient and not do_not_redirect:
_debug("Region passed for module invocation - {0} ".format(config["region"]))
_debug(f"Region passed for module invocation - {config['region']} ")
identity_client = IdentityClient(config)
region_subscriptions = identity_client.list_region_subscriptions(config["tenancy"]).data
# Replace the region in the config with the home region.
[config["region"]] = [rs.region_name for rs in region_subscriptions if rs.is_home_region is True]
_debug("Setting region in the config to home region - {0} ".format(config["region"]))
_debug(f"Setting region in the config to home region - {config['region']} ")
return config
@ -1282,7 +1282,7 @@ def wait_for_resource_lifecycle_state(
_debug(f"Waiting for resource to reach READY state. get_args: {kwargs_get}")
response_get = call_with_backoff(get_fn, **kwargs_get)
else:
_debug("Waiting for resource with id {0} to reach READY state.".format(resource["id"]))
_debug(f"Waiting for resource with id {resource['id']} to reach READY state.")
response_get = call_with_backoff(get_fn, **{get_param: resource["id"]})
if states is None:
states = module.params.get("wait_until") or DEFAULT_READY_STATES

View file

@ -338,11 +338,8 @@ class Snap(StateModuleHelper):
process_ = process_many
if "warning: no snap found" in check_error:
self.do_raise(
"Snaps not found: {0}.".format(
[x.split()[-1] for x in out.split("\n") if x.startswith("warning: no snap found")]
)
)
snaps_not_found = [x.split()[-1] for x in out.split("\n") if x.startswith("warning: no snap found")]
self.do_raise(f"Snaps not found: {snaps_not_found}.")
return process_(rc, out, err)
names = []

View file

@ -22,7 +22,6 @@ ignore = [
"UP045", # Use `X | None` for type annotations - needs Python 3.10+
# To fix:
"UP024", # Replace aliased errors with `OSError`
"UP030", # Use implicit references for positional format fields
"UP031", # Use format specifiers instead of percent format
"UP041", # Replace aliased errors with `TimeoutError`
"B026", # star-arg-unpacking-after-keyword-arg