Skip to content

Parse target-specific dependencies in Cargo.toml (fixes #5483) - #5484

Open
muskan-creates352 wants to merge 1 commit into
aboutcode-org:developfrom
muskan-creates352:parse-cargo-target-dependencies-5483
Open

muskan-creates352 wants to merge 1 commit into
aboutcode-org:developfrom
muskan-creates352:parse-cargo-target-dependencies-5483

Conversation

@muskan-creates352

Copy link
Copy Markdown

Fixes #5483

Problem

CargoTomlHandler in src/packagedcode/cargo.py only checked top-level keys ending in dependencies, causing all platform-specific / target-specific dependencies defined under [target.<target>.dependencies], [target.<target>.dev-dependencies], and [target.<target>.build-dependencies] to be silently ignored during scans.

Solution

  1. In src/packagedcode/cargo.py:
    • Updated CargoTomlHandler.parse to iterate through the target table and collect target dependencies.
    • Updated dependency_mapper to support receiving extra_data, attaching {"target": target_name} to each parsed DependentPackage.
    • Avoided in-place mutation of the requirement dictionary when popping optional.
  2. Added unit test test_parse_cargo_toml_target_dependencies in tests/packagedcode/test_cargo.py.
  3. Updated expected test fixtures for crates (clap, rustup, tauri) that define target dependencies.

Checklist

  • Signed-off-by included in commit message
  • Unit tests added and all 31 cargo tests pass
  • Tested on Python 3.11

…#5483)

Signed-off-by: Muskan Kumari <er.muskan09@gmail.com>

This branch has not been deployed

No deployments
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.

[BUG] CargoTomlHandler ignores target-specific dependencies in Cargo.toml

1 participant