Skip to content

Commit 64f1de3

Browse files
authored
Fix sort_by_dependency to work with non-standard dist names (#80)
1 parent 40df3b7 commit 64f1de3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stub_uploader/metadata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def sort_by_dependency(typeshed_dir: str, distributions: list[str]) -> Iterator[
224224
# for the first time that depend on each other.
225225
ts: graphlib.TopologicalSorter[str] = graphlib.TopologicalSorter()
226226

227+
dist_map: dict[str, str] = {} # maps stub distribution name to directory name
227228
for dist in os.listdir(os.path.join(typeshed_dir, THIRD_PARTY_NAMESPACE)):
228229
metadata = read_metadata(typeshed_dir, dist)
229230
ts.add(
@@ -234,12 +235,13 @@ def sort_by_dependency(typeshed_dir: str, distributions: list[str]) -> Iterator[
234235
# upload B.
235236
*[r.name for r in metadata._unvalidated_requires],
236237
)
238+
dist_map[metadata.stub_distribution] = dist
237239

238-
order = [strip_types_prefix(dist) for dist in ts.static_order()]
239-
missing = set(distributions) - set(order)
240+
ordered = [dist_map[stub_dist] for stub_dist in ts.static_order()]
241+
missing = set(distributions) - set(ordered)
240242
assert not missing, f"Failed to find distributions {missing}"
241243

242-
for dist in order:
244+
for dist in ordered:
243245
if dist in distributions:
244246
yield dist
245247

0 commit comments

Comments
 (0)