diff --git a/colcon_clean/base_handler/__init__.py b/colcon_clean/base_handler/__init__.py index 65efcb6..ce7aa98 100644 --- a/colcon_clean/base_handler/__init__.py +++ b/colcon_clean/base_handler/__init__.py @@ -74,7 +74,7 @@ def add_base_handler_arguments(parser): choices=extension_keys, default=extension_keys, help='Select base names to clean in workspace ' - '(default: {extension_keys})'.format_map(locals())) + f'(default: {extension_keys})') group.add_argument( '--base-ignore', nargs='*', metavar='BASE_NAME', diff --git a/colcon_clean/base_handler/build.py b/colcon_clean/base_handler/build.py index 1a9aee8..8fb504f 100644 --- a/colcon_clean/base_handler/build.py +++ b/colcon_clean/base_handler/build.py @@ -22,7 +22,7 @@ def add_arguments(self, *, parser): # noqa: D102 '--build-base', default=self.base_path, help='The base path for all build directories ' - '(default: {self.base_path})'.format_map(locals())) + f'(default: {self.base_path})') def get_workspace_paths(self, *, args): # noqa: D102 return [args.build_base] diff --git a/colcon_clean/base_handler/install.py b/colcon_clean/base_handler/install.py index dbcb8ef..c841839 100644 --- a/colcon_clean/base_handler/install.py +++ b/colcon_clean/base_handler/install.py @@ -22,7 +22,7 @@ def add_arguments(self, *, parser): # noqa: D102 '--install-base', default=self.base_path, help='The base path for all install directories ' - '(default: {self.base_path})'.format_map(locals())) + f'(default: {self.base_path})') def get_workspace_paths(self, *, args): # noqa: D102 return [args.install_base] diff --git a/colcon_clean/base_handler/log.py b/colcon_clean/base_handler/log.py index 2f9e5ad..edf1d1a 100644 --- a/colcon_clean/base_handler/log.py +++ b/colcon_clean/base_handler/log.py @@ -20,7 +20,7 @@ def add_arguments(self, *, parser): # noqa: D102 '--log-base', default=self.base_path, help='The base path for all log directories ' - '(default: {self.base_path})'.format_map(locals())) + f'(default: {self.base_path})') def get_workspace_paths(self, *, args): # noqa: D102 return [args.log_base] diff --git a/colcon_clean/base_handler/test_result.py b/colcon_clean/base_handler/test_result.py index e554676..a6e2ac7 100644 --- a/colcon_clean/base_handler/test_result.py +++ b/colcon_clean/base_handler/test_result.py @@ -24,7 +24,7 @@ def add_arguments(self, *, parser): # noqa: D102 '--test-result-base', default=self.base_path, help='The base path for all test_result directories ' - '(default: {self.base_path})'.format_map(locals())) + f'(default: {self.base_path})') def get_workspace_paths(self, *, args): # noqa: D102 return [args.test_result_base] diff --git a/colcon_clean/subverb/__init__.py b/colcon_clean/subverb/__init__.py index 03d121d..4ed0631 100644 --- a/colcon_clean/subverb/__init__.py +++ b/colcon_clean/subverb/__init__.py @@ -242,20 +242,17 @@ def clean_paths(paths, confirmed=False): _clean_path(path) -def _onerror(func, path, excinfo): # pragma: no cover - if excinfo[0] in (OSError, PermissionError): # pragma: no branch - logger.warning( - "Skipping path: '{path}'".format_map(locals())) - logger.info( - "Skipping info: '{excinfo[1]}'".format_map(locals())) +def _onexc(func, path, excinfo): # pragma: no cover + if isinstance(excinfo, (PermissionError, OSError)): # pragma: no branch + logger.warning(f"Skipping path: '{path}'") + logger.info(f"Skipping info: '{excinfo}'") return raise def _clean_path(path): - logger.info( - "Cleaning path: '{path}'".format_map(locals())) + logger.info(f"Cleaning path: '{path}'") if path.is_dir(): - shutil.rmtree(path, onerror=_onerror) + shutil.rmtree(path, onexc=_onexc) else: path.unlink() diff --git a/colcon_clean/subverb/packages.py b/colcon_clean/subverb/packages.py index fc12838..8bbdffe 100644 --- a/colcon_clean/subverb/packages.py +++ b/colcon_clean/subverb/packages.py @@ -48,9 +48,7 @@ def main(self, *, context): # noqa: D102 for base_name in args.base_select: if base_name in args.base_ignore: - logger.info( - "Ignoring base handler for selection '{base_name}'" - .format_map(locals())) + logger.info(f"Ignoring base handler for selection '{base_name}'") continue base_handler_extension = base_handler_extensions[base_name] for decorator in decorators: diff --git a/colcon_clean/subverb/workspace.py b/colcon_clean/subverb/workspace.py index 2dff71b..c22408e 100644 --- a/colcon_clean/subverb/workspace.py +++ b/colcon_clean/subverb/workspace.py @@ -43,9 +43,7 @@ def main(self, *, context): # noqa: D102 for base_name in args.base_select: if base_name in args.base_ignore: - logger.info( - "Ignoring base handler for selection '{base_name}'" - .format_map(locals())) + logger.info(f"Ignoring base handler for selection '{base_name}'") continue base_handler_extension = base_handler_extensions[base_name] workspace_paths = \ diff --git a/test/spell_check.words b/test/spell_check.words index 340dbb5..a7f70f2 100644 --- a/test/spell_check.words +++ b/test/spell_check.words @@ -19,6 +19,7 @@ mkdtemp monkeypatch nargs noqa +onexc pathlib plugin pydocstyle