Skip to content

Commit 53ae520

Browse files
authored
[BUG] fix broken version inspection if package distribution has None name (#1926)
Fixed the following bug pytorch_forecasting\utils\_dependencies\_dependencies.py:19, in _get_installed_packages_private() ---> 19 package_names = {dist.metadata["Name"] for dist in dists} TypeError: 'NoneType' object is not subscriptable #### Reference Issues/PRs Fixes #1925 #### What does this implement/fix? Explain your changes. Added exception handling to the original package_names = {dist.metadata["Name"] for dist in dists}
1 parent f93bd39 commit 53ae520

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytorch_forecasting/utils/_dependencies/_dependencies.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ def _get_installed_packages_private():
1616
from importlib.metadata import distributions, version
1717

1818
dists = distributions()
19-
package_names = {dist.metadata["Name"] for dist in dists}
19+
package_names = {
20+
dist.metadata["Name"]
21+
for dist in dists
22+
if dist.metadata and "Name" in dist.metadata
23+
}
2024
package_versions = {pkg_name: version(pkg_name) for pkg_name in package_names}
2125
# developer note:
2226
# we cannot just use distributions naively,

0 commit comments

Comments
 (0)