Merge pull request #1147 from ogayot/exception-string-interpolation

Fix exception messages not interpolated properly
This commit is contained in:
Dan Bungert 2021-12-16 16:26:50 -07:00 committed by GitHub
commit 7b3459ea9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 7 deletions

View File

@ -164,7 +164,7 @@ class Serializer:
serializer = self.type_serializers[annotation] serializer = self.type_serializers[annotation]
except KeyError: except KeyError:
raise Exception( raise Exception(
"do not know how to handle %s at %s", annotation, path) f"do not know how to handle {annotation} at {path}")
else: else:
return serializer(annotation, value, metadata, path) return serializer(annotation, value, metadata, path)

View File

@ -1417,7 +1417,7 @@ class FilesystemModel(object):
volume.flag == 'bios_grub' and fstype == 'fat32')): volume.flag == 'bios_grub' and fstype == 'fat32')):
raise Exception("{} is not available".format(volume)) raise Exception("{} is not available".format(volume))
if volume._fs is not None: if volume._fs is not None:
raise Exception("%s is already formatted", volume) raise Exception(f"{volume} is already formatted")
fs = Filesystem( fs = Filesystem(
m=self, volume=volume, fstype=fstype, preserve=preserve) m=self, volume=volume, fstype=fstype, preserve=preserve)
self._actions.append(fs) self._actions.append(fs)
@ -1430,7 +1430,7 @@ class FilesystemModel(object):
def add_mount(self, fs, path): def add_mount(self, fs, path):
if fs._mount is not None: if fs._mount is not None:
raise Exception("%s is already mounted", fs) raise Exception(f"{fs} is already mounted")
m = Mount(m=self, device=fs, path=path) m = Mount(m=self, device=fs, path=path)
self._actions.append(m) self._actions.append(m)
return m return m

View File

@ -100,7 +100,7 @@ class RefreshController(SubiquityController):
while True: while True:
change = await self.get_progress(change_id) change = await self.get_progress(change_id)
if change['status'] not in ['Do', 'Doing', 'Done']: if change['status'] not in ['Do', 'Doing', 'Done']:
raise Exception("update failed: %s", change['status']) raise Exception(f"update failed: {change['status']}")
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
@with_context() @with_context()

View File

@ -129,7 +129,7 @@ class MountSelector(WidgetWrap):
self._selector.value = OTHER self._selector.value = OTHER
self._showhide_other(True) self._showhide_other(True)
if not val.startswith('/'): if not val.startswith('/'):
raise ValueError("%s does not start with /", val) raise ValueError(f"{val} does not start with /")
self._other.value = val[1:] self._other.value = val[1:]

View File

@ -125,7 +125,7 @@ class Option:
self.enabled = True self.enabled = True
self.value = val self.value = val
else: else:
raise SelectorError("invalid option %r", val) raise SelectorError(f"invalid option {val!r}")
elif len(val) == 1: elif len(val) == 1:
self.label = val[0] self.label = val[0]
self.enabled = True self.enabled = True

View File

@ -57,4 +57,4 @@ def widget_width(w):
r += widget_width(w1) r += widget_width(w1)
r += (len(w.contents) - 1) * w.dividechars r += (len(w.contents) - 1) * w.dividechars
return r return r
raise Exception("don't know how to find width of %r", w) raise Exception(f"don't know how to find width of {w!r}")