From 6db194ecbc1033b1366689d00d02b842dbfd1de4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:03:52 +0000 Subject: [PATCH] =?UTF-8?q?ci(pre-commit.ci):=20=F0=9F=8E=A8=20Auto=20form?= =?UTF-8?q?at=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- micropy/app/stubs.py | 2 +- micropy/exceptions.py | 2 +- micropy/logger.py | 2 +- micropy/project/template.py | 8 ++++---- micropy/pyd/backend_upydevice.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/micropy/app/stubs.py b/micropy/app/stubs.py index 643332b2a..ec6560904 100644 --- a/micropy/app/stubs.py +++ b/micropy/app/stubs.py @@ -179,7 +179,7 @@ def _get_desc(name: str, cfg: dict): pyb.run_script(create_stubs, DevicePath(dev_path)) except Exception as e: # TODO: Handle more usage cases - log.error(f"Failed to execute script: {str(e)}", exception=e) + log.error(f"Failed to execute script: {e!s}", exception=e) raise log.success("Done!") log.info("Copying stubs...") diff --git a/micropy/exceptions.py b/micropy/exceptions.py index 94cf35109..137e85620 100644 --- a/micropy/exceptions.py +++ b/micropy/exceptions.py @@ -21,7 +21,7 @@ class StubValidationError(StubError): """Raised when a stub fails validation.""" def __init__(self, path, errors, *args, **kwargs): - msg = f"Stub at[{str(path)}] encountered" f" the following validation errors: {str(errors)}" + msg = f"Stub at[{path!s}] encountered" f" the following validation errors: {errors!s}" super().__init__(msg, *args, **kwargs) def __str__(self): diff --git a/micropy/logger.py b/micropy/logger.py index 80988741e..953c202c7 100644 --- a/micropy/logger.py +++ b/micropy/logger.py @@ -254,7 +254,7 @@ def exception(self, error, **kwargs): """ name = type(error).__name__ - msg = f"{name}: {str(error)}" + msg = f"{name}: {error!s}" return self.echo(msg, log="exception", title_color="red", fg="red", accent="red", **kwargs) def success(self, msg, **kwargs): diff --git a/micropy/project/template.py b/micropy/project/template.py index 3ae97febc..0bf17aa66 100644 --- a/micropy/project/template.py +++ b/micropy/project/template.py @@ -296,7 +296,7 @@ def render_to(self, name, parent_dir, *args, **kwargs): """ template = self.get(name, **kwargs) - self.log.debug(f"Loaded: {str(template)}") + self.log.debug(f"Loaded: {template!s}") if self.run_checks: self.log.debug(f"Verifying {template} requirements...") template.run_checks() @@ -305,7 +305,7 @@ def render_to(self, name, parent_dir, *args, **kwargs): self.log.debug(f"Create: {out_dir}") parent_dir.mkdir(exist_ok=True) out_dir.parent.mkdir(exist_ok=True, parents=True) - self.log.debug(f"Rendered: {name} to {str(out_dir)}") + self.log.debug(f"Rendered: {name} to {out_dir!s}") self.log.info(f"$[{name.capitalize()}] File Generated!") stream = template.render_stream() return stream.dump(str(out_dir)) @@ -326,13 +326,13 @@ def update(self, name, root_dir, **kwargs): """ template = self.get(name, **kwargs) - self.log.debug(f"Loaded: {str(template)}") + self.log.debug(f"Loaded: {template!s}") try: template.update(root_dir) except FileNotFoundError: self.log.debug("Template does not exist!") return self.render_to(name, root_dir, **kwargs) - self.log.debug(f"Updated: {str(template)}") + self.log.debug(f"Updated: {template!s}") return template @property diff --git a/micropy/pyd/backend_upydevice.py b/micropy/pyd/backend_upydevice.py index 834769333..413ffca42 100644 --- a/micropy/pyd/backend_upydevice.py +++ b/micropy/pyd/backend_upydevice.py @@ -203,7 +203,7 @@ def write_file( target_path = self.resolve_path(target_path) self._pydevice.cmd("import gc") self._pydevice.cmd("import ubinascii") - self._pydevice.cmd(f"f = open('{str(target_path)}', 'wb')") + self._pydevice.cmd(f"f = open('{target_path!s}', 'wb')") content_iter = ( iterutils.chunked_iter(contents, self.BUFFER_SIZE) @@ -212,7 +212,7 @@ def write_file( ) content_size = len(contents) - consumer.on_start(name=f"Writing {str(target_path)}", size=content_size) + consumer.on_start(name=f"Writing {target_path!s}", size=content_size) for chunk in content_iter: cmd = (