Skip to content

Commit 1d84d8f

Browse files
Preserve case and quoted spaces in dependency requirements
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent a841c7c commit 1d84d8f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/python_inspector/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def get_dependency(specifier) -> DependentPackage:
6565
>>> dep = get_dependency("foo==1.2.3")
6666
>>> assert dep.purl == "pkg:pypi/foo@1.2.3"
6767
"""
68-
specifier = specifier and "".join(specifier.lower().split())
68+
specifier = specifier and specifier.strip()
6969
assert specifier, f"specifier is required but empty:{specifier!r}"
7070

7171
requirement = Requirement(requirement_string=specifier)

tests/test_requirement_text.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
3+
from python_inspector.dependencies import get_dependency
4+
5+
@pytest.mark.parametrize(
6+
"text",
7+
['Demo==1.2; sys_platform == "Windows Server"', "Demo @ https://example.org/Release/Demo.whl"],
8+
)
9+
def test_dependency_preserves_requirement_text(text):
10+
dependency = get_dependency(" " + text + " ")
11+
assert dependency.extracted_requirement == text
12+
assert dependency.purl.startswith("pkg:pypi/demo")

0 commit comments

Comments
 (0)