From 1d84d8fcf51b6f308b48b4abfb54105ae80a8e0c Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:21:31 +0500 Subject: [PATCH 1/3] Preserve case and quoted spaces in dependency requirements Signed-off-by: Ali Zulfiqar --- src/python_inspector/dependencies.py | 2 +- tests/test_requirement_text.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/test_requirement_text.py diff --git a/src/python_inspector/dependencies.py b/src/python_inspector/dependencies.py index 0c491304..31328fc3 100644 --- a/src/python_inspector/dependencies.py +++ b/src/python_inspector/dependencies.py @@ -65,7 +65,7 @@ def get_dependency(specifier) -> DependentPackage: >>> dep = get_dependency("foo==1.2.3") >>> assert dep.purl == "pkg:pypi/foo@1.2.3" """ - specifier = specifier and "".join(specifier.lower().split()) + specifier = specifier and specifier.strip() assert specifier, f"specifier is required but empty:{specifier!r}" requirement = Requirement(requirement_string=specifier) diff --git a/tests/test_requirement_text.py b/tests/test_requirement_text.py new file mode 100644 index 00000000..100dd666 --- /dev/null +++ b/tests/test_requirement_text.py @@ -0,0 +1,12 @@ +import pytest + +from python_inspector.dependencies import get_dependency + +@pytest.mark.parametrize( + "text", + ['Demo==1.2; sys_platform == "Windows Server"', "Demo @ https://example.org/Release/Demo.whl"], +) +def test_dependency_preserves_requirement_text(text): + dependency = get_dependency(" " + text + " ") + assert dependency.extracted_requirement == text + assert dependency.purl.startswith("pkg:pypi/demo") From 9a77593a241c68dd91714a7505e1c62308d0bec3 Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:31:26 +0500 Subject: [PATCH 2/3] Address review feedback and strengthen regression coverage Signed-off-by: Ali Zulfiqar --- tests/test_requirement_text.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_requirement_text.py b/tests/test_requirement_text.py index 100dd666..98b8bf4c 100644 --- a/tests/test_requirement_text.py +++ b/tests/test_requirement_text.py @@ -1,3 +1,7 @@ +# Copyright (c) nexB Inc. and others. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# See https://github.com/aboutcode-org/python-inspector for support or download. + import pytest from python_inspector.dependencies import get_dependency From f36486923079d0cd710d36489957b1162b6aa935 Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:35:41 +0500 Subject: [PATCH 3/3] Apply repository formatting to regression tests Signed-off-by: Ali Zulfiqar --- tests/test_requirement_text.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_requirement_text.py b/tests/test_requirement_text.py index 98b8bf4c..4dc9607a 100644 --- a/tests/test_requirement_text.py +++ b/tests/test_requirement_text.py @@ -6,6 +6,7 @@ from python_inspector.dependencies import get_dependency + @pytest.mark.parametrize( "text", ['Demo==1.2; sys_platform == "Windows Server"', "Demo @ https://example.org/Release/Demo.whl"],