Commit 18c2903b by Jace Tan Committed by GitHub

fix: handle distribution.files being None (#6877)

We discovered that in some unknown situations, `distribution.files` can
be `None`, causing the assertion to fail. To handle `distribution.files`
being `None` more gracefully, we treat it as if it were an empty list.

Resolves: #6788 
parent 0dc3d54f
......@@ -328,8 +328,8 @@ class SitePackages:
for distribution in self.distributions(
name=distribution_name, writable_only=writable_only
):
assert distribution.files is not None
for file in distribution.files:
files = [] if distribution.files is None else distribution.files
for file in files:
if file.name.endswith(suffix):
yield Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
......@@ -341,8 +341,8 @@ class SitePackages:
for distribution in self.distributions(
name=distribution_name, writable_only=writable_only
):
assert distribution.files is not None
for file in distribution.files:
files = [] if distribution.files is None else distribution.files
for file in files:
if file.name == name:
yield Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
......@@ -372,8 +372,8 @@ class SitePackages:
for distribution in self.distributions(
name=distribution_name, writable_only=True
):
assert distribution.files is not None
for file in distribution.files:
files = [] if distribution.files is None else distribution.files
for file in files:
path = Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment