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 Nov 1, 2022
1 parent 432ba1a commit b329759
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from __future__ import annotations

import logging
import re
import sys
import warnings

from collections import defaultdict
from pathlib import Path
from typing import TYPE_CHECKING

from poetry.core.utils.patterns import AUTHOR_REGEX


if TYPE_CHECKING:
from poetry.core.poetry import Poetry


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

METADATA_BASE = """\
Metadata-Version: 2.1
Name: {name}
Expand Down
4 changes: 1 addition & 3 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import copy
import re

from contextlib import contextmanager
from pathlib import Path
Expand All @@ -16,6 +15,7 @@
from poetry.core.packages.dependency_group import MAIN_GROUP
from poetry.core.packages.specification import PackageSpecification
from poetry.core.packages.utils.utils import create_nested_marker
from poetry.core.utils.patterns import AUTHOR_REGEX
from poetry.core.version.exceptions import InvalidVersion
from poetry.core.version.markers import parse_marker

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

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

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


class Package(PackageSpecification):
AVAILABLE_PYTHONS = {
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
8 changes: 3 additions & 5 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ 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),
],
)
def test_package_authors_valid(name: str, email: str | None) -> None:
Expand All @@ -101,12 +102,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 b329759

Please sign in to comment.