Skip to content

Commit 3d7ee19

Browse files
committed
Refactor to avoid missed coverage
1 parent 8818432 commit 3d7ee19

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Diff for: importlib_metadata/__init__.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import functools
1313
import itertools
1414
import posixpath
15+
import contextlib
1516
import collections
1617
import inspect
1718

@@ -513,16 +514,14 @@ def _read_files_egginfo_installed(self):
513514
# But this subdir is only available in the PathDistribution's self._path
514515
# which is not easily accessible from this base class...
515516
subdir = getattr(self, '_path', None)
516-
try:
517-
if text and subdir:
518-
ret = [
519-
str((subdir / line).resolve().relative_to(self.locate_file('')))
520-
for line in text.splitlines()
521-
]
522-
return map('"{}"'.format, ret)
523-
except Exception:
524-
pass
525-
return None
517+
if not text or not subdir:
518+
return
519+
with contextlib.suppress(Exception):
520+
ret = [
521+
str((subdir / line).resolve().relative_to(self.locate_file('')))
522+
for line in text.splitlines()
523+
]
524+
return map('"{}"'.format, ret)
526525

527526
def _read_files_egginfo_sources(self):
528527
"""

0 commit comments

Comments
 (0)