Skip to content

Commit 6ec6448

Browse files
committed
In PackageNotFoundError, make reference to the package metadata being missing to improve the user experience. Closes #124.
1 parent e4e555d commit 6ec6448

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

importlib_metadata/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@
5555
class PackageNotFoundError(ModuleNotFoundError):
5656
"""The package was not found."""
5757

58+
def __str__(self):
59+
tmpl = "No package metadata was found for {self.name}"
60+
return tmpl.format(**locals())
61+
62+
@property
63+
def name(self):
64+
name, = self.args
65+
return name
66+
5867

5968
class EntryPoint(
6069
PyPy_repr,

0 commit comments

Comments
 (0)