mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Address issues reported by ruff check (#11043)
* Resolve E713 and E714 (not in/is tests). * Address UP018 (unnecessary str call). * UP045 requires Python 3.10+. * Address UP007 (X | Y for type annotations). * Address UP035 (import Callable from collections.abc). * Address UP006 (t.Dict -> dict). * Address UP009 (UTF-8 encoding comment). * Address UP034 (extraneous parantheses). * Address SIM910 (dict.get() with None default). * Address F401 (unused import). * Address UP020 (use builtin open). * Address B009 and B010 (getattr/setattr with constant name). * Address SIM300 (Yoda conditions). * UP029 isn't in use anyway. * Address FLY002 (static join). * Address B034 (re.sub positional args). * Address B020 (loop variable overrides input). * Address B017 (assert raise Exception). * Address SIM211 (if expression with false/true). * Address SIM113 (enumerate for loop). * Address UP036 (sys.version_info checks). * Remove unnecessary UP039. * Address SIM201 (not ==). * Address SIM212 (if expr with twisted arms). * Add changelog fragment. * Reformat.
This commit is contained in:
@@ -455,7 +455,7 @@ def delete_target(module, headers):
|
||||
)
|
||||
|
||||
status = info.get("status", 0)
|
||||
if not status == 200:
|
||||
if status != 200:
|
||||
module.fail_json(msg=f"Failed to delete: HTTP {status}, {response}, {headers}")
|
||||
|
||||
except Exception as e:
|
||||
@@ -605,7 +605,7 @@ def run_module():
|
||||
does_exist = target_exists(module)
|
||||
|
||||
# Check if the credential/domain doesn't exist and the user wants to delete
|
||||
if not does_exist and state == "absent" and not type == "token":
|
||||
if not does_exist and state == "absent" and type != "token":
|
||||
result["changed"] = False
|
||||
result["msg"] = f"{id} does not exist."
|
||||
module.exit_json(**result)
|
||||
@@ -762,7 +762,7 @@ def run_module():
|
||||
|
||||
payload = {"credentials": credentials}
|
||||
|
||||
if not type == "file" and not type == "token":
|
||||
if type != "file" and type != "token":
|
||||
body = urlencode({"json": json.dumps(payload)})
|
||||
|
||||
else: # Delete
|
||||
@@ -770,7 +770,7 @@ def run_module():
|
||||
|
||||
module.exit_json(changed=True, msg=f"{id} deleted successfully.")
|
||||
|
||||
if not type == "scope" and not scope == "_": # Check if custom scope exists if adding to a custom scope
|
||||
if type != "scope" and scope != "_": # Check if custom scope exists if adding to a custom scope
|
||||
if not target_exists(module, True):
|
||||
module.fail_json(msg=f"Domain {scope} doesn't exists")
|
||||
|
||||
@@ -781,7 +781,7 @@ def run_module():
|
||||
|
||||
status = info.get("status", 0)
|
||||
|
||||
if not status == 200:
|
||||
if status != 200:
|
||||
body = response.read() if response else b""
|
||||
module.fail_json(
|
||||
msg=f"Failed to {'add/update' if state == 'present' else 'delete'} credential",
|
||||
|
||||
Reference in New Issue
Block a user