Skip to content

Commit

Permalink
format with black with experimental-string-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Jul 24, 2023
1 parent 3e91870 commit 0517a52
Show file tree
Hide file tree
Showing 38 changed files with 89 additions and 97 deletions.
2 changes: 1 addition & 1 deletion console_conf/cmd/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

def parse_options(argv):
parser = argparse.ArgumentParser(
description=("console-conf - Pre-Ownership Configuration for Ubuntu Core"),
description="console-conf - Pre-Ownership Configuration for Ubuntu Core",
prog="console-conf",
)
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions console_conf/ui/views/chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def back(self, result):

class ChooserView(ChooserBaseView):
excerpt = (
"Select one of available recovery systems and a desired " "action to execute."
"Select one of available recovery systems and a desired action to execute."
)

def __init__(self, controller, systems):
Expand Down Expand Up @@ -173,7 +173,7 @@ def back(self, result):
class ChooserConfirmView(ChooserBaseView):
canned_summary = {
"run": "Continue running the system without any changes.",
"recover": ("You have requested to reboot the system into recovery " "mode."),
"recover": "You have requested to reboot the system into recovery mode.",
"install": (
"You are about to {action_lower} the system version "
"{version} for {model} from {publisher}.\n\n"
Expand Down
2 changes: 1 addition & 1 deletion console_conf/ui/views/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
log = logging.getLogger("console_conf.ui.views.identity")

sso_help = (
"If you do not have an account, visit " "https://login.ubuntu.com to create one."
"If you do not have an account, visit https://login.ubuntu.com to create one."
)


Expand Down
5 changes: 1 addition & 4 deletions subiquity/client/controllers/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ async def _fetch_ssh_keys(self, *, context, ssh_import_id, ssh_data):
elif response.status == SSHFetchIdStatus.FINGERPRINT_ERROR:
if isinstance(self.ui.body, SSHView):
self.ui.body.fetching_ssh_keys_failed(
_(
"ssh-keygen failed to show fingerprint of"
" downloaded keys:"
),
_("ssh-keygen failed to show fingerprint of downloaded keys:"),
response.error,
)
return
Expand Down
2 changes: 1 addition & 1 deletion subiquity/cmd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def make_server_args_parser():
"--snap-section",
action="store",
default="server",
help=("Show snaps from this section of the store in the snap " "list screen."),
help="Show snaps from this section of the store in the snap list screen.",
)
parser.add_argument("--source-catalog", dest="source_catalog", action="store")
parser.add_argument(
Expand Down
5 changes: 3 additions & 2 deletions subiquity/common/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ def _make_handler(
for param_name, param in def_params.items():
if param_name in ("request", "context"):
raise Exception(
"api method {} cannot have parameter called request or "
"context".format(definition)
"api method {} cannot have parameter called request or context".format(
definition
)
)
if getattr(param.annotation, "__origin__", None) is Payload:
data_arg = param_name
Expand Down
12 changes: 5 additions & 7 deletions subiquity/common/filesystem/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def _can_edit_generic(device):
cd = device.constructed_device()
if cd is None:
return True
return _(
"Cannot edit {selflabel} as it is part of the {cdtype} " "{cdname}."
).format(
return _("Cannot edit {selflabel} as it is part of the {cdtype} {cdname}.").format(
selflabel=labels.label(device), cdtype=labels.desc(cd), cdname=labels.label(cd)
)

Expand Down Expand Up @@ -193,7 +191,7 @@ def _can_edit_vg(vg):
if vg.preserve:
return _("Cannot edit pre-existing volume groups.")
elif len(vg._partitions) > 0:
return _("Cannot edit {vglabel} because it has logical " "volumes.").format(
return _("Cannot edit {vglabel} because it has logical volumes.").format(
vglabel=labels.label(vg)
)
else:
Expand Down Expand Up @@ -249,7 +247,7 @@ def _can_remove_device(device):
return False
if cd.preserve:
return _(
"Cannot remove {selflabel} from pre-existing {cdtype} " "{cdlabel}."
"Cannot remove {selflabel} from pre-existing {cdtype} {cdlabel}."
).format(
selflabel=labels.label(device),
cdtype=labels.desc(cd),
Expand Down Expand Up @@ -290,7 +288,7 @@ def _can_delete_generic(device):
if cd is None:
return True
return _(
"Cannot delete {selflabel} as it is part of the {cdtype} " "{cdname}."
"Cannot delete {selflabel} as it is part of the {cdtype} {cdname}."
).format(
selflabel=labels.label(device), cdtype=labels.desc(cd), cdname=labels.label(cd)
)
Expand Down Expand Up @@ -330,7 +328,7 @@ def _can_delete_raid_vg(device):
)
if mounted_partitions > 1:
return _(
"Cannot delete {devicelabel} because it has {count} mounted " "partitions."
"Cannot delete {devicelabel} because it has {count} mounted partitions."
).format(devicelabel=labels.label(device), count=mounted_partitions)
elif mounted_partitions == 1:
return _(
Expand Down
2 changes: 1 addition & 1 deletion subiquity/common/filesystem/manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def create_partition(self, device, gap, spec, **kw):
if gap.in_extended:
if flag not in (None, "logical"):
log.debug(
f"overriding flag {flag} " "due to being in an extended partition"
f"overriding flag {flag} due to being in an extended partition"
)
flag = "logical"
part = self.model.add_partition(
Expand Down
4 changes: 2 additions & 2 deletions subiquity/models/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InconsistentMultiLayoutError(ValueError):

def __init__(self, layouts: str, variants: str) -> None:
super().__init__(
f'inconsistent multi-layout: layouts="{layouts}"' f' variants="{variants}"'
f'inconsistent multi-layout: layouts="{layouts}" variants="{variants}"'
)


Expand Down Expand Up @@ -112,7 +112,7 @@ def validate_setting(self, setting: KeyboardSetting) -> None:
kbd_variant.code == variant for kbd_variant in kbd_layout.variants
):
raise ValueError(
f'Unknown keyboard variant "{variant}" ' f'for layout "{layout}"'
f'Unknown keyboard variant "{variant}" for layout "{layout}"'
)

def render_config_file(self):
Expand Down
2 changes: 1 addition & 1 deletion subiquity/models/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def load_autoinstall_data(self, data):

if "primary" in data and "mirror-selection" in data:
raise ValueError(
"apt->primary and apt->mirror-selection are" " mutually exclusive."
"apt->primary and apt->mirror-selection are mutually exclusive."
)
self.legacy_primary = "primary" in data

Expand Down
5 changes: 2 additions & 3 deletions subiquity/models/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def render(self):
r = {
"write_files": {
"etc_netplan_installer": {
"path": ("etc/cloud/cloud.cfg.d/90-installer-network.cfg"),
"path": "etc/cloud/cloud.cfg.d/90-installer-network.cfg",
"content": self.stringify_config(netplan),
"permissions": "0600",
},
Expand Down Expand Up @@ -104,8 +104,7 @@ async def is_nm_enabled(self):
cp = await arun_command(("nmcli", "networking"), check=True)
except subprocess.CalledProcessError as exc:
log.warning(
"failed to run nmcli networking,"
" considering NetworkManager disabled."
"failed to run nmcli networking, considering NetworkManager disabled."
)
log.debug("stderr: %s", exc.stderr)
return False
Expand Down
4 changes: 1 addition & 3 deletions subiquity/models/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def render(self):
},
"write_files": {
"snapd_dropin": {
"path": (
"etc/systemd/system/" "snapd.service.d/snap_proxy.conf"
),
"path": "etc/systemd/system/snapd.service.d/snap_proxy.conf",
"content": self.proxy_systemd_dropin(),
"permissions": 0o644,
},
Expand Down
6 changes: 3 additions & 3 deletions subiquity/models/tests/test_subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_cloud_init_user_list_merge(self, run_cmd):
with self.assertRaises(SchemaValidationError) as ctx:
model._cloud_init_config()
expected_error = (
"Cloud config schema errors: bootcmd: 'nope' is not of type" " 'array'"
"Cloud config schema errors: bootcmd: 'nope' is not of type 'array'"
)
self.assertEqual(expected_error, str(ctx.exception))

Expand Down Expand Up @@ -314,7 +314,7 @@ def test_cloud_init_files_emits_datasource_config_and_clean_script(
cfg_files.remove("/etc/cloud/cloud.cfg.d/90-installer-network.cfg")
cfg_files.append("/etc/netplan/00-installer-config.yaml")
cfg_files.append(
"/etc/cloud/cloud.cfg.d/" "subiquity-disable-cloudinit-networking.cfg"
"/etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg"
)
expected_files[
"etc/cloud/clean.d/99-installer"
Expand Down Expand Up @@ -379,7 +379,7 @@ def __init__(self, schema_errors=(), schema_deprecations=()):
data={"bootcmd": "nope"}, data_source="system info"
)
expected_error = (
"Cloud config schema errors: bootcmd: 'nope' is not of" " type 'array'"
"Cloud config schema errors: bootcmd: 'nope' is not of type 'array'"
)
self.assertEqual(expected_error, str(ctx.exception))

Expand Down
6 changes: 3 additions & 3 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ async def apply_autoinstall_config(self, context=None):
raise Exception("autoinstall config did not mount root")
if self.model.needs_bootloader_partition():
raise Exception(
"autoinstall config did not create needed bootloader " "partition"
"autoinstall config did not create needed bootloader partition"
)

def update_devices(self, device_map):
Expand Down Expand Up @@ -1160,7 +1160,7 @@ async def run_autoinstall_guided(self, layout):
core_boot_caps.update(variation.capability_info.allowed)
if not core_boot_caps:
raise Exception(
"can only use name: hybrid when installing core boot " "classic"
"can only use name: hybrid when installing core boot classic"
)
if "mode" in layout:
raise Exception("cannot use 'mode' when installing core boot classic")
Expand Down Expand Up @@ -1196,7 +1196,7 @@ async def run_autoinstall_guided(self, layout):
break
else:
raise Exception(
"must use name: hybrid when installing core boot " "classic"
"must use name: hybrid when installing core boot classic"
)
mode = layout.get("mode", "reformat_disk")
self.validate_layout_mode(mode)
Expand Down
5 changes: 3 additions & 2 deletions subiquity/server/controllers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ async def POST(self, data: IdentityData):
validated = await self.validate_username_GET(data.username)
if validated != UsernameValidation.OK:
raise ValueError(
"Username <{}> is invalid and should not be"
" submitted.".format(data.username),
"Username <{}> is invalid and should not be submitted.".format(
data.username
),
validated,
)

Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/controllers/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ async def stop_unattended_upgrades(self):
[
"chroot",
self.tpath(),
"/usr/share/unattended-upgrades/" "unattended-upgrade-shutdown",
"/usr/share/unattended-upgrades/unattended-upgrade-shutdown",
"--stop-only",
]
)
Expand Down
4 changes: 2 additions & 2 deletions subiquity/server/controllers/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def apply_fallback(self):
fallback = self.model.fallback

if fallback == MirrorSelectionFallback.ABORT:
log.error("aborting the install since no primary mirror is" " usable")
log.error("aborting the install since no primary mirror is usable")
# TODO there is no guarantee that raising this exception will
# actually abort the install. If this is raised from a request
# handler, for instance, it will just return a HTTP 500 error. For
Expand All @@ -240,7 +240,7 @@ async def apply_fallback(self):
raise RuntimeError("aborting install since no mirror is usable")
elif fallback == MirrorSelectionFallback.OFFLINE_INSTALL:
log.warning(
"reverting to an offline install since no primary" " mirror is usable"
"reverting to an offline install since no primary mirror is usable"
)
self.app.base_model.network.force_offline = True
elif fallback == MirrorSelectionFallback.CONTINUE_ANYWAY:
Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/controllers/oem.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async def load_metapackages_list(self, context) -> None:
variant: str = self.app.base_model.source.current.variant
fs_controller = self.app.controllers.Filesystem
if fs_controller.is_core_boot_classic():
log.debug("listing of OEM meta-packages disabled on core boot" " classic")
log.debug("listing of OEM meta-packages disabled on core boot classic")
self.model.metapkgs = []
return
if not self.model.install_on[variant]:
Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/controllers/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def configure_snapd(self, context):
and snap.channel != expected_channel
):
log.debug(
f"snap tracking {snap.channel}, not resetting based " "on .disk/info"
f"snap tracking {snap.channel}, not resetting based on .disk/info"
)
return
desc = "switching {} to {}".format(self.snap_name, channel)
Expand Down
6 changes: 4 additions & 2 deletions subiquity/server/ubuntu_advantage.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ async def magic_wait_v1(self, magic_token: str) -> dict:
"result": "failure",
"errors": [
{
"title": "The magic attach token is invalid, has "
" expired or never existed",
"title": (
"The magic attach token is invalid, has "
" expired or never existed"
),
"code": "magic-attach-token-error",
},
],
Expand Down
3 changes: 1 addition & 2 deletions subiquity/ui/views/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ def make_main(self, install: bool, drivers: List[str]) -> None:
)

excerpt = _(
"The following third-party drivers were found. "
"Do you want to install them?"
"The following third-party drivers were found. Do you want to install them?"
)

def on_cancel(_: DriversForm) -> None:
Expand Down
5 changes: 2 additions & 3 deletions subiquity/ui/views/filesystem/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ def validate_devices(self):
potential_boot_disks.add(d)
if not potential_boot_disks - set(mdc.value):
return _(
"\
If you put all disks into RAIDs or LVM VGs, there will be nowhere \
to put the boot partition."
"If you put all disks into RAIDs or LVM VGs, there will be nowhere"
" to put the boot partition."
)


Expand Down
10 changes: 5 additions & 5 deletions subiquity/ui/views/filesystem/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def __init__(self, parent, obj):
if m is not None:
lines.append(
Text(
_(
"It is formatted as {fstype} and mounted at " "{path}"
).format(fstype=fs.fstype, path=m.path)
_("It is formatted as {fstype} and mounted at {path}").format(
fstype=fs.fstype, path=m.path
)
)
)
else:
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, parent, obj):
m = fs.mount()
if m is not None:
lines.append(
_("It is formatted as {fstype} and mounted at " "{path}").format(
_("It is formatted as {fstype} and mounted at {path}").format(
fstype=fs.fstype, path=m.path
)
)
Expand All @@ -147,7 +147,7 @@ def __init__(self, parent, obj):
things=things, obj=labels.desc(obj)
)
lines = [
_("Do you really want to remove all {things} from " "{obj}?").format(
_("Do you really want to remove all {things} from {obj}?").format(
things=things, obj=labels.label(obj)
),
"",
Expand Down
6 changes: 2 additions & 4 deletions subiquity/ui/views/filesystem/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _change_encrypt(self, sender, new_value):

def validate_devices(self):
if len(self.devices.value) < 1:
return _("Select at least one device to be part of the volume " "group.")
return _("Select at least one device to be part of the volume group.")

def validate_name(self):
v = self.name.value
Expand All @@ -102,9 +102,7 @@ def validate_name(self):
)
if v in (".", "..", "md") or os.path.exists("/dev/" + v):
if v not in self.deleted_vg_names:
return _("{name} is not a valid name for a volume " "group").format(
name=v
)
return _("{name} is not a valid name for a volume group").format(name=v)

def validate_passphrase(self):
if self.encrypt.value and len(self.passphrase.value) < 1:
Expand Down
2 changes: 1 addition & 1 deletion subiquity/ui/views/filesystem/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def validate_name(self):
]:
if substring in v:
return _(
"The name of a logical volume may not contain " '"{substring}"'
'The name of a logical volume may not contain "{substring}"'
).format(substring=substring)
if v in self.lvm_names:
return _("There is already a logical volume named {name}.").format(
Expand Down
Loading

0 comments on commit 0517a52

Please sign in to comment.