Skip to content

Commit 788682c

Browse files
committed
fix: make AUTHOR_REGEX less restrictive
1 parent 737a203 commit 788682c

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/poetry/core/packages/package.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import re
43
import warnings
54

65
from typing import TYPE_CHECKING
@@ -13,6 +12,7 @@
1312
from poetry.core.constraints.version.exceptions import ParseConstraintError
1413
from poetry.core.packages.dependency_group import MAIN_GROUP
1514
from poetry.core.packages.specification import PackageSpecification
15+
from poetry.core.utils.patterns import AUTHOR_REGEX
1616
from poetry.core.version.exceptions import InvalidVersionError
1717

1818

@@ -32,10 +32,6 @@
3232

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

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

4036
class Package(PackageSpecification):
4137
AVAILABLE_PYTHONS: ClassVar[set[str]] = {

src/poetry/core/utils/patterns.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import re
44

55

6+
AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[^<>]+)(?: <(?P<email>.+?)>)?$")
7+
68
wheel_file_re = re.compile(
79
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
810
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)

tests/packages/test_package.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def test_package_authors_invalid() -> None:
8383
("John-Paul: Doe", None),
8484
("John-Paul: Doe", "[email protected]"),
8585
("John Doe the 3rd", "[email protected]"),
86+
("FirstName LastName [email protected]", None),
87+
("Surname, Given Name [Department]", None),
8688
],
8789
)
8890
def test_package_authors_valid(name: str, email: str | None) -> None:
@@ -98,12 +100,9 @@ def test_package_authors_valid(name: str, email: str | None) -> None:
98100
("name",),
99101
[
100102
101-
103+
104+
102105
("<John Doe",),
103-
("John? Doe",),
104-
("Jane+Doe",),
105-
("~John Doe",),
106-
("John~Doe",),
107106
],
108107
)
109108
def test_package_author_names_invalid(name: str) -> None:

0 commit comments

Comments
 (0)