mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-08 21:17:20 +00:00
[PR #11043/3478863e backport][stable-12] Address issues reported by ruff check (#11047)
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.
(cherry picked from commit 3478863ef0)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
11b802372b
commit
16f1d07509
77 changed files with 196 additions and 222 deletions
|
|
@ -11,7 +11,6 @@ import os
|
|||
import stat
|
||||
import time
|
||||
import fcntl
|
||||
import sys
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
|
@ -59,9 +58,6 @@ class FileLock:
|
|||
"""
|
||||
lock_path = os.path.join(tmpdir, f"ansible-{os.path.basename(path)}.lock")
|
||||
l_wait = 0.1
|
||||
r_exception = IOError
|
||||
if sys.version_info[0] == 3:
|
||||
r_exception = BlockingIOError
|
||||
|
||||
self.lockfd = open(lock_path, "w")
|
||||
|
||||
|
|
@ -77,7 +73,7 @@ class FileLock:
|
|||
fcntl.flock(self.lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
os.chmod(lock_path, stat.S_IWRITE | stat.S_IREAD)
|
||||
return True
|
||||
except r_exception:
|
||||
except BlockingIOError:
|
||||
time.sleep(l_wait)
|
||||
e_secs += l_wait
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ class BtrfsSubvolume:
|
|||
return mountpoints is not None and len(mountpoints) > 0
|
||||
|
||||
def is_filesystem_root(self):
|
||||
return 5 == self.__subvolume_id
|
||||
return self.__subvolume_id == 5
|
||||
|
||||
def is_filesystem_default(self):
|
||||
return self.__filesystem.default_subvolid == self.__subvolume_id
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ from __future__ import annotations
|
|||
|
||||
# pylint: disable=unused-import
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.mh.module_helper import (
|
||||
from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ( # noqa: F401
|
||||
ModuleHelper,
|
||||
StateModuleHelper,
|
||||
)
|
||||
from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException # noqa: F401
|
||||
from ansible_collections.community.general.plugins.module_utils.mh.deco import (
|
||||
from ansible_collections.community.general.plugins.module_utils.mh.deco import ( # noqa: F401
|
||||
cause_changes,
|
||||
module_fails_on_exception,
|
||||
check_mode_skip,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ def get_resource(oneandone_conn, resource_type, resource_id):
|
|||
"vpn": oneandone_conn.get_vpn,
|
||||
}
|
||||
|
||||
return switcher.get(resource_type, None)(resource_id)
|
||||
return switcher.get(resource_type)(resource_id)
|
||||
|
||||
|
||||
def get_datacenter(oneandone_conn, datacenter, full_object=False):
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class OpenNebulaModule:
|
|||
if "cluster_name" in self.module.params:
|
||||
clusters = self.one.clusterpool.info()
|
||||
for cluster in clusters.CLUSTER:
|
||||
if cluster.NAME == self.module.params.get("cluster_name"):
|
||||
if self.module.params.get("cluster_name") == cluster.NAME:
|
||||
resolved_params["cluster_id"] = cluster.ID
|
||||
|
||||
return resolved_params
|
||||
|
|
@ -223,7 +223,7 @@ class OpenNebulaModule:
|
|||
"""
|
||||
hosts = self.one.hostpool.info()
|
||||
for h in hosts.HOST:
|
||||
if h.NAME == name:
|
||||
if name == h.NAME:
|
||||
return h
|
||||
return None
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ class OpenNebulaModule:
|
|||
|
||||
clusters = self.one.clusterpool.info()
|
||||
for c in clusters.CLUSTER:
|
||||
if c.NAME == name:
|
||||
if name == c.NAME:
|
||||
return c
|
||||
return None
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ class OpenNebulaModule:
|
|||
"""
|
||||
templates = self.one.templatepool.info()
|
||||
for t in templates.TEMPLATE:
|
||||
if t.NAME == name:
|
||||
if name == t.NAME:
|
||||
return t
|
||||
return None
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ class OpenNebulaModule:
|
|||
intersection[dkey] = current[dkey]
|
||||
else:
|
||||
return True
|
||||
return not (desired == intersection)
|
||||
return desired != intersection
|
||||
|
||||
def wait_for_state(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue