Python code modernization, 1/n (#1141)

* Remove unicode text prefixes.

* Replace str.format() uses with f-strings.

* Replace % with f-strings, and do some cleanup.

* Fix wrong variable.

* Avoid unnecessary string conversion.
This commit is contained in:
Felix Fontein
2025-10-06 18:30:54 +02:00
committed by GitHub
parent 1f2817fa20
commit f45232635c
93 changed files with 930 additions and 1122 deletions
+3 -3
View File
@@ -146,14 +146,14 @@ class ContextAPI(object):
names.append(name)
except Exception as e:
raise errors.ContextException(
"Failed to load metafile {filepath}: {e}".format(filepath=filepath, e=e),
f"Failed to load metafile {filepath}: {e}"
) from e
contexts = [cls.get_default_context()]
for name in names:
context = Context.load_context(name)
if not context:
raise errors.ContextException("Context {context} cannot be found".format(context=name))
raise errors.ContextException(f"Context {name} cannot be found")
contexts.append(context)
return contexts
@@ -174,7 +174,7 @@ class ContextAPI(object):
err = write_context_name_to_docker_config(name)
if err:
raise errors.ContextException(
'Failed to set current context: {err}'.format(err=err))
f'Failed to set current context: {err}')
@classmethod
def remove_context(cls, name):