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: make AUTHOR_REGEX less restrictive #517

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import re
import warnings

from typing import TYPE_CHECKING
Expand All @@ -13,6 +12,7 @@
from poetry.core.constraints.version.exceptions import ParseConstraintError
from poetry.core.packages.dependency_group import MAIN_GROUP
from poetry.core.packages.specification import PackageSpecification
from poetry.core.utils.patterns import AUTHOR_REGEX
from poetry.core.version.exceptions import InvalidVersionError


Expand All @@ -32,10 +32,6 @@

T = TypeVar("T", bound="Package")

AUTHOR_REGEX = re.compile(
r"(?u)^(?P<name>[- .,\w\d'’\"():&]+)(?: <(?P<email>.+?)>)?$" # noqa: RUF001
)


class Package(PackageSpecification):
AVAILABLE_PYTHONS: ClassVar[set[str]] = {
Expand Down
2 changes: 2 additions & 0 deletions src/poetry/core/utils/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import re


AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[^<>]+)(?: <(?P<email>.+?)>)?$")

wheel_file_re = re.compile(
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
Expand Down
9 changes: 4 additions & 5 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def test_package_authors_invalid() -> None:
("John-Paul: Doe", None),
("John-Paul: Doe", "[email protected]"),
("John Doe the 3rd", "[email protected]"),
("FirstName LastName [email protected]", None),
("Surname, Given Name [Department]", None),
],
)
def test_package_authors_valid(name: str, email: str | None) -> None:
Expand All @@ -98,12 +100,9 @@ def test_package_authors_valid(name: str, email: str | None) -> None:
("name",),
[
("<[email protected]>",),
("[email protected]",),
("<[email protected]",),
("[email protected]>",),
("<John Doe",),
("John? Doe",),
("Jane+Doe",),
("~John Doe",),
("John~Doe",),
],
)
def test_package_author_names_invalid(name: str) -> None:
Expand Down
Loading