Skip to content

fix(formats): resolve nested remote requirement URLs - #3851

Merged
frostming merged 1 commit into
pdm-project:mainfrom
tunglambk:fix/remote-requirements-relative-url
Aug 17, 2026
Merged

fix(formats): resolve nested remote requirement URLs#3851
frostming merged 1 commit into
pdm-project:mainfrom
tunglambk:fix/remote-requirements-relative-url

Conversation

@tunglambk

Copy link
Copy Markdown
Contributor

Summary

  • resolve relative nested -r references against a remote requirements file URL
  • preserve absolute nested HTTP(S) and file URLs
  • keep the existing local-file path resolution unchanged
  • add offline regression coverage for sibling, parent-directory, and absolute URL references

Root cause and impact

RequirementParser._parse_line() resolved every nested requirements reference with pathlib.Path. For a remote parent such as https://example.com/base/requirements.txt, this collapsed the URL into https:/example.com/base/child.txt, so importing a valid remote requirements tree failed at the first relative -r line.

The parser now uses URL joining when the parent is remote, while retaining Path joining for local files.

Fixes #3850.

Validation

  • pytest -q tests/test_formats.py (56 passed)
  • ruff check src/pdm/formats/requirements.py tests/test_formats.py
  • ruff format --check src/pdm/formats/requirements.py tests/test_formats.py
  • git diff --check

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.44%. Comparing base (95a7777) to head (b49f0dd).

Files with missing lines Patch % Lines
src/pdm/formats/requirements.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3851      +/-   ##
==========================================
+ Coverage   88.43%   88.44%   +0.01%     
==========================================
  Files         121      121              
  Lines       13262    13268       +6     
  Branches     2252     2254       +2     
==========================================
+ Hits        11728    11735       +7     
+ Misses        965      964       -1     
  Partials      569      569              
Flag Coverage Δ
unittests 88.33% <71.42%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frostming
frostming merged commit b15d75d into pdm-project:main Aug 17, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing a remote requirements file breaks relative -r URLs

2 participants