Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wheel_file_re RegExp #9770

Merged
merged 9 commits into from
Oct 16, 2024
12 changes: 6 additions & 6 deletions src/poetry/utils/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


wheel_file_re = re.compile(
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))"
r"(-(?P<build>\d.*?))?"
r"-(?P<pyver>.+?)"
r"-(?P<abi>.+?)"
r"-(?P<plat>.+?)"
r"\.whl|\.dist-info$",
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d[^-]*))"
r"(-(?P<build>\d[^-]*))?"
r"-(?P<pyver>[^-]+)"
r"-(?P<abi>[^-]+)"
r"-(?P<plat>[^-]+)"
r"\.whl$",
re.VERBOSE,
)

Expand Down
18 changes: 18 additions & 0 deletions tests/utils/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
"plat": "manylinux2010_x86_64",
},
),
(
"isort-metadata-4.3.4-py2-none-any.whl",
{
"namever": "isort-metadata-4.3.4",
"name": "isort-metadata",
"ver": "4.3.4",
"build": None,
"pyver": "py2",
"abi": "none",
"plat": "any",
},
),
],
)
def test_wheel_file_re(filename: str, expected: dict[str, str | None]) -> None:
Expand All @@ -42,6 +54,12 @@ def test_wheel_file_re(filename: str, expected: dict[str, str | None]) -> None:
assert groups == expected


@pytest.mark.parametrize("filename", [".dist-info"])
def test_wheel_file_re_not_matches(filename: str) -> None:
match = patterns.wheel_file_re.match(filename)
assert match is None


AlekseyLobanov marked this conversation as resolved.
Show resolved Hide resolved
@pytest.mark.parametrize(
["filename", "expected"],
[
Expand Down
Loading