Skip to content

Commit

Permalink
fix: make AUTHOR_REGEX less restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
finswimmer committed Oct 25, 2024
1 parent eb68b29 commit ad175f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
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

0 comments on commit ad175f8

Please sign in to comment.