Skip to content

Commit 5992511

Browse files
committed
fix(bazel): address pypi review nits
1 parent a3f1742 commit 5992511

3 files changed

Lines changed: 16 additions & 22 deletions

File tree

src/commands/manifest/bazel/bazel-pypi-discovery.mts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,19 @@ export async function discoverPypiHubs(
403403
: `static parse (${parsed.length})`,
404404
)
405405
}
406-
// Seed with the default hub name first (so it appears first in output if
407-
// validated). Parsed candidates overwrite the seed when they share the same
408-
// hub name so metadata (requirements_lock, python_version) is preserved.
409-
const seen = new Set<string>()
410-
const candidates: PypiHubCandidate[] = []
411-
for (const c of parsed) {
412-
if (!seen.has(c.hubName)) {
413-
seen.add(c.hubName)
414-
candidates.push(c)
415-
}
416-
}
417-
if (!seen.has(DEFAULT_PYPI_HUB_SEED)) {
418-
candidates.unshift({
419-
hubName: DEFAULT_PYPI_HUB_SEED,
420-
source: 'default-seed',
421-
workspaceMode: 'unknown',
422-
})
423-
}
406+
// Prepend the default hub seed unless parsed metadata already covers it.
407+
const candidates: PypiHubCandidate[] = parsed.some(
408+
c => c.hubName === DEFAULT_PYPI_HUB_SEED,
409+
)
410+
? parsed
411+
: [
412+
{
413+
hubName: DEFAULT_PYPI_HUB_SEED,
414+
source: 'default-seed',
415+
workspaceMode: 'unknown',
416+
},
417+
...parsed,
418+
]
424419
if (verbose) {
425420
logger.log(
426421
'[VERBOSE] discovery: candidate set to probe (seed-first, deduped):',

src/commands/manifest/bazel/bazel-repo-discovery.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ function apparentNamesFromRepoMapping(value: unknown): string[] {
118118
if (name.startsWith('@') || typeof canonicalName !== 'string') {
119119
continue
120120
}
121-
const repo = normalizeRepoName(name)
122-
if (repo) {
123-
candidates.push(repo)
121+
if (BAZEL_REPO_NAME_RE.test(name)) {
122+
candidates.push(name)
124123
}
125124
}
126125
return candidates

src/commands/manifest/bazel/extract_bazel_to_pypi.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type ExtractBazelToPypiOptions = {
4747
cwd: string
4848
env?: NodeJS.ProcessEnv
4949
out: string
50-
outLayout?: 'flat'
50+
outLayout?: 'flat' | 'standalone'
5151
verbose: boolean
5252
explicitEcosystem?: boolean
5353
}

0 commit comments

Comments
 (0)