mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
batch 1 - update Python idiom to 3.7 using pyupgrade (#11341)
* batch 1 - update Python idiom to 3.7 using pyupgrade * add changelog frag * add changelog frag
This commit is contained in:
parent
a0d3bac88c
commit
5b5f7e9e64
19 changed files with 48 additions and 29 deletions
|
|
@ -163,7 +163,7 @@ def get_profile(params):
|
|||
else f"{os.getenv('HOME')}/.aliyun/config.json"
|
||||
)
|
||||
auth = {}
|
||||
with open(path, "r") as f:
|
||||
with open(path) as f:
|
||||
for pro in json.load(f)["profiles"]:
|
||||
if params["profile"] == pro["name"]:
|
||||
auth = pro
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ def not_in_host_file(self, host):
|
|||
try:
|
||||
with open(hf) as host_fh:
|
||||
data = host_fh.read()
|
||||
except IOError:
|
||||
except OSError:
|
||||
hfiles_not_found += 1
|
||||
continue
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class LXDClient:
|
|||
return resp_json
|
||||
self._raise_err_from_json(resp_json)
|
||||
return resp_json
|
||||
except socket.error as e:
|
||||
except OSError as e:
|
||||
raise LXDClientException("cannot connect to the LXD server", err=e) from e
|
||||
|
||||
def _raise_err_from_json(self, resp_json):
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ class ManageIQPolicies:
|
|||
|
||||
# make a list of assigned full profile names strings
|
||||
# e.g. ['openscap profile', ...]
|
||||
assigned_profiles_set = set(profile["profile_name"] for profile in assigned_profiles)
|
||||
assigned_profiles_set = {profile["profile_name"] for profile in assigned_profiles}
|
||||
|
||||
for profile in profiles:
|
||||
assigned = profile.get("name") in assigned_profiles_set
|
||||
|
|
@ -398,7 +398,7 @@ class ManageIQTags:
|
|||
|
||||
# make a list of assigned full tag names strings
|
||||
# e.g. ['/managed/environment/prod', ...]
|
||||
assigned_tags_set = set(tag["full_name"] for tag in assigned_tags)
|
||||
assigned_tags_set = {tag["full_name"] for tag in assigned_tags}
|
||||
|
||||
for tag in tags:
|
||||
assigned = self.full_tag_name(tag) in assigned_tags_set
|
||||
|
|
|
|||
|
|
@ -1352,7 +1352,7 @@ def delete_and_wait(
|
|||
:return: A dictionary containing the resource & the "changed" status. e.g. {"vcn":{x:y}, "changed":True}
|
||||
"""
|
||||
|
||||
states_set = set(["DETACHING", "DETACHED", "DELETING", "DELETED", "TERMINATING", "TERMINATED"])
|
||||
states_set = {"DETACHING", "DETACHED", "DELETING", "DELETED", "TERMINATING", "TERMINATED"}
|
||||
result: dict[str, t.Any] = dict(changed=False)
|
||||
result[resource_type] = dict()
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ def uldap():
|
|||
|
||||
def construct():
|
||||
try:
|
||||
secret_file = open("/etc/ldap.secret", "r")
|
||||
secret_file = open("/etc/ldap.secret")
|
||||
bind_dn = f"cn=admin,{base_dn()}"
|
||||
except IOError: # pragma: no cover
|
||||
secret_file = open("/etc/machine.secret", "r")
|
||||
except OSError: # pragma: no cover
|
||||
secret_file = open("/etc/machine.secret")
|
||||
bind_dn = config_registry()["ldap/hostdn"]
|
||||
pwd_line = secret_file.readline()
|
||||
pwd = re.sub("\n", "", pwd_line)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue