[elbe-devel] [PATCH v2 50/75] hashes: use f-strings

Bastian Germann bage at linutronix.de
Sun Nov 6 18:50:20 CET 2022


Am 02.11.22 um 20:14 schrieb Daniel Braunwarth:
> Signed-off-by: Daniel Braunwarth <daniel at braunwarth.dev>
> ---
>   elbepack/hashes.py | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/elbepack/hashes.py b/elbepack/hashes.py
> index dc3c54156..ecd0e2daa 100644
> --- a/elbepack/hashes.py
> +++ b/elbepack/hashes.py
> @@ -20,8 +20,8 @@ def validate_sha256(fname, expected_hash):
>               buf = f.read(65536)
>       if m.hexdigest() != expected_hash:
>           raise HashValidationFailed(
> -                'file "%s" failed to verify ! got: "%s" expected: "%s"' %
> -                (fname, m.hexdigest(), expected_hash))
> +                f'file "{fname}" failed to verify ! got: "{m.hexdigest()}" '
> +                f'expected: "{expected_hash}"')
>   
>   class HashValidator:
>       def __init__(self, base_url):
> @@ -43,8 +43,8 @@ class HashValidator:
>       def download_and_validate_file(self, upstream_fname, local_fname):
>           url = self.base_url + upstream_fname
>           try:
> -            system('wget -O "%s" "%s"' % (local_fname, url))
> +            system('wget -O "{local_fname}" "{url}"')

This is missing the "f" in f-string.
This leads me to the conclusion that the whole conversion was done manually.
What did you do to validate the changes?

>           except CommandError:
> -            raise HashValidationFailed('Failed to download %s' % url)
> +            raise HashValidationFailed(f"Failed to download {url}")
>   
>           self.validate_file(upstream_fname, local_fname)


More information about the elbe-devel mailing list