Skip to content

Commit

Permalink
chore(black): Bump version (canonical#5607)
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Aug 14, 2024
1 parent 2bb49b4 commit 56658ec
Show file tree
Hide file tree
Showing 80 changed files with 168 additions and 141 deletions.
2 changes: 1 addition & 1 deletion cloudinit/cmd/devel/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_parser(parser=None):
make_mime.handle_args,
),
]
for (subcmd, helpmsg, get_parser, handler) in subcmds:
for subcmd, helpmsg, get_parser, handler in subcmds:
parser = subparsers.add_parser(subcmd, help=helpmsg)
get_parser(parser)
parser.set_defaults(action=(subcmd, handler))
Expand Down
1 change: 1 addition & 0 deletions cloudinit/config/cc_ansible.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ansible enables running on first boot either ansible-pull"""

import abc
import logging
import os
Expand Down
6 changes: 2 additions & 4 deletions cloudinit/config/cc_growpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ def __init__(self, distro: Distro):
self._distro = distro

@abstractmethod
def available(self, devices: list) -> bool:
...
def available(self, devices: list) -> bool: ...

@abstractmethod
def resize(self, diskdev, partnum, partdev, fs):
...
def resize(self, diskdev, partnum, partdev, fs): ...


class ResizeGrowPart(Resizer):
Expand Down
4 changes: 2 additions & 2 deletions cloudinit/config/cc_phone_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
"pub_key_ed25519": "/etc/ssh/ssh_host_ed25519_key.pub",
}

for (n, path) in pubkeys.items():
for n, path in pubkeys.items():
try:
all_keys[n] = util.load_text_file(path)
except Exception:
Expand All @@ -117,7 +117,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:

# Get them read to be posted
real_submit_keys = {}
for (k, v) in submit_keys.items():
for k, v in submit_keys.items():
if v is None:
real_submit_keys[k] = "N/A"
else:
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/cc_resizefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
return

fstype_lc = fs_type.lower()
for (pfix, root_cmd) in RESIZE_FS_PREFIXES_CMDS:
for pfix, root_cmd in RESIZE_FS_PREFIXES_CMDS:
if fstype_lc.startswith(pfix):
resizer = root_cmd
break
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
if "ssh_keys" in cfg:
# if there are keys and/or certificates in cloud-config, use them
cert_config = []
for (key, val) in cfg["ssh_keys"].items():
for key, val in cfg["ssh_keys"].items():
if key not in CONFIG_KEY_TO_FILE:
if pattern_unsupported_config_keys.match(key):
reason = "unsupported"
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ssh_authkey_fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:

hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "sha256")
(users, _groups) = ug_util.normalize_users_groups(cfg, cloud.distro)
for (user_name, _cfg) in users.items():
for user_name, _cfg in users.items():
if _cfg.get("no_create_home") or _cfg.get("system"):
LOG.debug(
"Skipping printing of ssh fingerprints for user '%s' because "
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ssh_import_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
# import for cloudinit created users
(users, _groups) = ug_util.normalize_users_groups(cfg, cloud.distro)
elist = []
for (user, user_cfg) in users.items():
for user, user_cfg in users.items():
import_ids = []
if user_cfg["default"]:
import_ids = util.get_cfg_option_list(cfg, "ssh_import_id", [])
Expand Down
4 changes: 2 additions & 2 deletions cloudinit/config/cc_users_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
(default_user, _user_config) = ug_util.extract_default(users)
cloud_keys = cloud.get_public_ssh_keys() or []

for (name, members) in groups.items():
for name, members in groups.items():
cloud.distro.create_group(name, members)

for (user, config) in users.items():
for user, config in users.items():

no_home = [key for key in NO_HOME if config.get(key)]
need_home = [key for key in NEED_HOME if config.get(key)]
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/cc_write_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def write_files(name, files, owner: str, ssl_details: Optional[dict] = None):
if not files:
return

for (i, f_info) in enumerate(files):
for i, f_info in enumerate(files):
path = f_info.get("path")
if not path:
LOG.warning(
Expand Down
8 changes: 4 additions & 4 deletions cloudinit/config/cc_yum_add_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _format_repository_config(repo_id, repo_config):
to_be = ConfigParser()
to_be.add_section(repo_id)
# Do basic translation of the items -> values
for (k, v) in repo_config.items():
for k, v in repo_config.items():
# For now assume that people using this know
# the format of yum and don't verify keys/values further
to_be.set(repo_id, k, _format_repo_value(v))
Expand All @@ -114,7 +114,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
)
repo_locations = {}
repo_configs = {}
for (repo_id, repo_config) in repos.items():
for repo_id, repo_config in repos.items():
canon_repo_id = _canonicalize_id(repo_id)
repo_fn_pth = os.path.join(repo_base_path, "%s.repo" % (canon_repo_id))
if os.path.exists(repo_fn_pth):
Expand All @@ -135,7 +135,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
repo_config = {}
# Do some basic sanity checks/cleaning
n_repo_config = {}
for (k, v) in repo_config.items():
for k, v in repo_config.items():
k = k.lower().strip().replace("-", "_")
if k:
n_repo_config[k] = v
Expand All @@ -157,7 +157,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
repo_configs[canon_repo_id] = repo_config
repo_locations[canon_repo_id] = repo_fn_pth

for (c_repo_id, path) in repo_locations.items():
for c_repo_id, path in repo_locations.items():
repo_blob = _format_repository_config(
c_repo_id, repo_configs.get(c_repo_id)
)
Expand Down
4 changes: 2 additions & 2 deletions cloudinit/config/cc_zypper_add_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _format_repository_config(repo_id, repo_config):
to_be = configobj.ConfigObj()
to_be[repo_id] = {}
# Do basic translation of the items -> values
for (k, v) in repo_config.items():
for k, v in repo_config.items():
# For now assume that people using this know the format
# of zypper repos and don't verify keys/values further
to_be[repo_id][k] = _format_repo_value(v)
Expand Down Expand Up @@ -115,7 +115,7 @@ def _write_repos(repos, repo_base_path):

valid_repos[repo_id] = (repo_fn_pth, repo_config)

for (repo_id, repo_data) in valid_repos.items():
for repo_id, repo_data in valid_repos.items():
repo_blob = _format_repository_config(repo_id, repo_data[-1])
util.write_file(repo_data[0], repo_blob)

Expand Down
6 changes: 3 additions & 3 deletions cloudinit/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,9 @@ def get_meta_doc(meta: MetaSchema, schema: Optional[dict] = None) -> str:
LOG.warning("Unable to render property_doc due to invalid schema")
meta_copy["property_doc"] = ""
if not meta_copy.get("property_doc", ""):
meta_copy[
"property_doc"
] = " No schema definitions for this module"
meta_copy["property_doc"] = (
" No schema definitions for this module"
)
meta_copy["examples"] = textwrap.indent(_get_examples(meta), " ")
if not meta_copy["examples"]:
meta_copy["examples"] = " No examples for this module"
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/distros/aosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def update_locale_conf(sys_path, locale_cfg):
return
(exists, contents) = read_locale_conf(sys_path)
updated_am = 0
for (k, v) in locale_cfg.items():
for k, v in locale_cfg.items():
if v is None:
continue
v = str(v)
Expand Down
3 changes: 1 addition & 2 deletions cloudinit/distros/package_management/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def available(self) -> bool:
"""Return if package manager is installed on system."""

@abstractmethod
def update_package_sources(self, *, force=False):
...
def update_package_sources(self, *, force=False): ...

@abstractmethod
def install_packages(self, pkglist: Iterable) -> UninstalledPackages:
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/distros/parsers/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def parse(self):
def __str__(self):
self.parse()
contents = StringIO()
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "blank":
contents.write("%s\n" % (components[0]))
elif line_type == "all_comment":
Expand All @@ -39,7 +39,7 @@ def __str__(self):
@property
def hostname(self):
self.parse()
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "hostname":
return components[0]
return None
Expand All @@ -50,7 +50,7 @@ def set_hostname(self, your_hostname):
return
self.parse()
replaced = False
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "hostname":
components[0] = str(your_hostname)
replaced = True
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/distros/parsers/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def parse(self):
def get_entry(self, ip):
self.parse()
options = []
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "option":
(pieces, _tail) = components
if len(pieces) and pieces[0] == ip:
Expand All @@ -34,7 +34,7 @@ def get_entry(self, ip):
def del_entries(self, ip):
self.parse()
n_entries = []
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type != "option":
n_entries.append((line_type, components))
continue
Expand Down Expand Up @@ -68,7 +68,7 @@ def _parse(self, contents):
def __str__(self):
self.parse()
contents = StringIO()
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "blank":
contents.write("%s\n" % (components[0]))
elif line_type == "all_comment":
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/distros/parsers/resolv_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def search_domains(self):
def __str__(self):
self.parse()
contents = StringIO()
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "blank":
contents.write("\n")
elif line_type == "all_comment":
Expand All @@ -72,7 +72,7 @@ def __str__(self):

def _retr_option(self, opt_name):
found = []
for (line_type, components) in self._contents:
for line_type, components in self._contents:
if line_type == "option":
(cfg_opt, cfg_value, _comment_tail) = components
if cfg_opt == opt_name:
Expand Down Expand Up @@ -134,7 +134,7 @@ def add_search_domain(self, search_domain):

def _parse(self, contents):
entries = []
for (i, line) in enumerate(contents.splitlines()):
for i, line in enumerate(contents.splitlines()):
sline = line.strip()
if not sline:
entries.append(("blank", [line]))
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/distros/rhel_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def update_sysconfig_file(fn, adjustments, allow_empty=False):
return
(exists, contents) = read_sysconfig_file(fn)
updated_am = 0
for (k, v) in adjustments.items():
for k, v in adjustments.items():
if v is None:
continue
v = str(v)
Expand Down
12 changes: 6 additions & 6 deletions cloudinit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ def _unpickle(self, ci_pkl_version: int) -> None:
if "instance_data" not in self.lookups:
self.lookups["instance_data"] = "instance-data.json"
if "instance_data_sensitive" not in self.lookups:
self.lookups[
"instance_data_sensitive"
] = "instance-data-sensitive.json"
self.lookups["instance_data_sensitive"] = (
"instance-data-sensitive.json"
)
if "combined_cloud_config" not in self.lookups:
self.lookups[
"combined_cloud_config"
] = "combined-cloud-config.json"
self.lookups["combined_cloud_config"] = (
"combined-cloud-config.json"
)
if "hotplug.enabled" not in self.lookups:
self.lookups["hotplug.enabled"] = "hotplug.enabled"

Expand Down
4 changes: 2 additions & 2 deletions cloudinit/mergers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def default_mergers():

def construct(parsed_mergers):
mergers_to_be = []
for (m_name, m_ops) in parsed_mergers:
for m_name, m_ops in parsed_mergers:
if not m_name.startswith(MERGER_PREFIX):
m_name = MERGER_PREFIX + str(m_name)
merger_locs, looked_locs = importer.find_module(
Expand All @@ -147,6 +147,6 @@ def construct(parsed_mergers):
# Now form them...
mergers = []
root = LookupMerger(mergers)
for (attr, opts) in mergers_to_be:
for attr, opts in mergers_to_be:
mergers.append(attr(root, opts))
return root
2 changes: 1 addition & 1 deletion cloudinit/mergers/m_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def merge_same_key(old_v, new_v):
# Otherwise leave it be...
return old_v

for (k, v) in merge_with.items():
for k, v in merge_with.items():
if k in value:
if v is None and self._allow_delete:
value.pop(k)
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def _get_current_rename_info(check_downable=True):
}}
"""
cur_info = {}
for (name, mac, driver, device_id) in get_interfaces():
for name, mac, driver, device_id in get_interfaces():
cur_info[name] = {
"downable": None,
"device_id": device_id,
Expand Down
8 changes: 4 additions & 4 deletions cloudinit/net/ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ def obtain_lease(self):
kwargs["prefix_or_mask"], kwargs["ip"]
)
if kwargs["static_routes"]:
kwargs[
"static_routes"
] = self.distro.dhcp_client.parse_static_routes(
kwargs["static_routes"]
kwargs["static_routes"] = (
self.distro.dhcp_client.parse_static_routes(
kwargs["static_routes"]
)
)
ephipv4 = EphemeralIPv4Network(
self.distro,
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets, flavor):
@classmethod
def _render_bonding_opts(cls, iface_cfg, iface, flavor):
bond_opts = []
for (bond_key, value_tpl) in cls.bond_tpl_opts:
for bond_key, value_tpl in cls.bond_tpl_opts:
# Seems like either dash or underscore is possible?
bond_keys = [bond_key, bond_key.replace("_", "-")]
for bond_key in bond_keys:
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/netinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def netdev_pformat():
return "\n"
fields = ["Device", "Up", "Address", "Mask", "Scope", "Hw-Address"]
tbl = SimpleTable(fields)
for (dev, data) in sorted(netdev.items()):
for dev, data in sorted(netdev.items()):
for addr in data.get("ipv4"):
tbl.add_row(
(
Expand Down Expand Up @@ -635,7 +635,7 @@ def route_pformat():
"Flags",
]
tbl_v4 = SimpleTable(fields_v4)
for (n, r) in enumerate(routes.get("ipv4")):
for n, r in enumerate(routes.get("ipv4")):
route_id = str(n)
try:
tbl_v4.add_row(
Expand Down Expand Up @@ -663,7 +663,7 @@ def route_pformat():
"Flags",
]
tbl_v6 = SimpleTable(fields_v6)
for (n, r) in enumerate(routes.get("ipv6")):
for n, r in enumerate(routes.get("ipv6")):
route_id = str(n)
if r["iface"] == "lo":
continue
Expand Down
Loading

0 comments on commit 56658ec

Please sign in to comment.