Bug
In scripts/check-readme-links.py, check_relative_file_links has an unreachable guard:
# scripts/check-readme-links.py:223-227
for target in iter_links(path):
normalized, anchor = split_link_target(target)
if not normalized.startswith(("./", "../")):
continue
if not normalized:
continue
The second if not normalized: continue can never fire. The line immediately above already continues for every value of normalized that does not start with "./" or "../". Any string that survives to line 227 therefore begins with "./" or "../", which makes it non-empty by construction, so not normalized is always False.
Reproduction
Purely by reading: there is no input for which line 227's continue is taken. The branch is dead code.
It looks like the intent may have been to skip empty targets before the prefix check (a link like [x]() produces an empty target). As written, an empty target hits line 225 ("".startswith(("./", "../")) is False) and is skipped there, so the emptiness check is both misordered and redundant.
Suggested Fix
Either drop the redundant guard entirely, or — if the goal was to defend against empty/odd targets generally — move it above the prefix check so it actually does something:
normalized, anchor = split_link_target(target)
if not normalized:
continue
if not normalized.startswith(("./", "../")):
continue
Low impact (CI helper, no behavior change today), but it's a small readability snag that suggests the validation order isn't quite what was intended.
Bug
In
scripts/check-readme-links.py,check_relative_file_linkshas an unreachable guard:The second
if not normalized: continuecan never fire. The line immediately above alreadycontinues for every value ofnormalizedthat does not start with"./"or"../". Any string that survives to line 227 therefore begins with"./"or"../", which makes it non-empty by construction, sonot normalizedis alwaysFalse.Reproduction
Purely by reading: there is no input for which line 227's
continueis taken. The branch is dead code.It looks like the intent may have been to skip empty targets before the prefix check (a link like
[x]()produces an empty target). As written, an empty target hits line 225 ("".startswith(("./", "../"))isFalse) and is skipped there, so the emptiness check is both misordered and redundant.Suggested Fix
Either drop the redundant guard entirely, or — if the goal was to defend against empty/odd targets generally — move it above the prefix check so it actually does something:
Low impact (CI helper, no behavior change today), but it's a small readability snag that suggests the validation order isn't quite what was intended.