Skip to content

Fix Maven and NuGet from_native for bare versions and unbounded ranges - #222

Open
lahari936 wants to merge 1 commit into
aboutcode-org:mainfrom
lahari936:fix-maven-soft-requirement
Open

lahari936 wants to merge 1 commit into
aboutcode-org:mainfrom
lahari936:fix-maven-soft-requirement

Conversation

@lahari936

Copy link
Copy Markdown

Fixes #221

Problem

MavenVersionRange.from_native("1.0") and from_native("(,)") both return vers:maven/None. For a bare version, maven.VersionRange keeps the version in .version and adds an empty Restriction() with both bounds None. from_native() ignored .version, and lower_bound == upper_bound was true for None == None, so it created a constraint on the version string "None".

NugetVersionRange inherits this method, so NugetVersionRange.from_native("1.0") crashed with InvalidNuGetVersion: version does not contain any digit: None.

Changes

Maven (MavenVersionRange.from_native)

  • A bare version (soft requirement) becomes an exact version: 1.0 → vers:maven/1.0. This is the version Maven picks when nothing else conflicts, and it matches how a bare version is handled for other schemes.
  • A range with no bounds becomes *: (,) and [,] → vers:maven/*.

NuGet (NugetVersionRange.from_native, a new override)

Testing

  • Added 4 tests in tests/test_maven_version_range.py. All 4 fail on main and pass with this change.
  • Full suite: 7311 passed. Three tests fail the same way on main and are unrelated: test_codestyle, test_semver_version and test_enhanced_semantic_version.
  • Doctests pass, and black passes.

If maintainers would rather map a Maven soft requirement to *, I can change it. It is one line.

A bare Maven version such as "1.0" and an unbounded range such as "(,)"
were converted to a constraint on the version string "None", giving
"vers:maven/None". NuGet inherits this method and crashed instead.

Map a Maven soft requirement to the exact version and an unbounded
range to "*". Add a NuGet override: NuGet treats a bare version as a
minimum version (">=") and does not allow unbounded ranges.

Fixes aboutcode-org#221

Signed-off-by: lahari <laharir832@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 00:27

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. Try requesting a review at a lower effort level.

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.

MavenVersionRange.from_native returns vers:maven/None for bare versions and unbounded ranges

2 participants