diff --git a/src/poetry/masonry/builders/editable.py b/src/poetry/masonry/builders/editable.py index a2bb9a514b7..93c06a7e729 100644 --- a/src/poetry/masonry/builders/editable.py +++ b/src/poetry/masonry/builders/editable.py @@ -132,8 +132,7 @@ def _add_pth(self) -> list[Path]: f" {self._poetry.file.path.parent}" ) return [pth_file] - except OSError: - # TODO: Replace with PermissionError + except PermissionError: self._io.write_error_line( f" - Failed to create {pth_file.name} for" f" {self._poetry.file.path.parent}" diff --git a/src/poetry/utils/_compat.py b/src/poetry/utils/_compat.py index 535615d9a26..f2d6157343f 100644 --- a/src/poetry/utils/_compat.py +++ b/src/poetry/utils/_compat.py @@ -10,14 +10,11 @@ from pathlib import Path -# TODO: use try/except ImportError when -# https://github.com/python/mypy/issues/1393 is fixed - if sys.version_info < (3, 11): # compatibility for python <3.11 import tomli as tomllib else: - import tomllib # nopycln: import + import tomllib if sys.version_info < (3, 10): diff --git a/src/poetry/utils/env/site_packages.py b/src/poetry/utils/env/site_packages.py index d762e4d344c..b7f50dbcf63 100644 --- a/src/poetry/utils/env/site_packages.py +++ b/src/poetry/utils/env/site_packages.py @@ -169,14 +169,11 @@ def _path_method_wrapper( results = [] for candidate in candidates: - try: + with contextlib.suppress(OSError): result = candidate, getattr(candidate, method)(*args, **kwargs) if return_first: return result results.append(result) - except OSError: - # TODO: Replace with PermissionError - pass if results: return results