Skip to content

fix(pypi): track exact PKG-INFO line numbers for license findings - #5541

Open
Adnan9-63 wants to merge 1 commit into
aboutcode-org:developfrom
Adnan9-63:fix/pypi-pkg-info-license-line-numbers
Open

Adnan9-63 wants to merge 1 commit into
aboutcode-org:developfrom
Adnan9-63:fix/pypi-pkg-info-license-line-numbers

Conversation

@Adnan9-63

Copy link
Copy Markdown

What changes does this PR introduce?

This PR resolves issue #5454 by tracking exact line numbers for license expressions and classifiers directly from PKG-INFO / METADATA files instead of defaulting to lines 1–1.

Specifically:

  1. Accurate Line Mapping in src/packagedcode/pypi.py:
    • Computes 1-based start and end line numbers when parsing License:, Classifier:, and License-Expression: metadata fields from PKG-INFO and METADATA.
    • Passes exact line ranges through build_license_detections() to ensure reported line numbers match file locations.
  2. Fixture Updates:
    • Updated package-level test fixtures across tests/packagedcode/data/pypi/ with exact lines.
    • Surgically updated tests/packagedcode/data/pypi/unpacked_sdist/prefer-egg-info-pkg-info/celery-expected.json while preserving all file references.
  3. Unit Tests:
    • Added regression test suite in tests/packagedcode/test_pypi.py verifying license start and end lines for single-line and multi-line metadata.

Fixes #5454

Checklist

  • Code passes tests: pytest tests/packagedcode/test_pypi.py
  • DCO sign-off applied to commit

Copilot AI balanced review requested due to automatic review settings November 24, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@Adnan9-63
Adnan9-63 requested a lite review from Copilot November 24, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

Misleading license finding in PKG-INFO in case of --package option

2 participants