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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
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", "jp@nomail.none"),
("John Doe the 3rd", "3rd@jd.net"),
("FirstName LastName firstname.lastname@company.com", None),
("Surname, Given Name [Department]", None),
],
)
def test_package_authors_valid(name: str, email: str | None) -> None:
Expand All @@ -101,12 +103,9 @@ def test_package_authors_valid(name: str, email: str | None) -> None:
("name",),
[
("<john@john.doe>",),
("john@john.doe",),
("<john@john.doe",),
("john@john.doe>",),
("<John Doe",),
("John? Doe",),
("Jane+Doe",),
("~John Doe",),
("John~Doe",),
],
)
def test_package_author_names_invalid(name: str) -> None:
Expand Down