From b329759ba09fa3b34f13ec4142df54567b30ca0a Mon Sep 17 00:00:00 2001 From: finswimmer Date: Tue, 1 Nov 2022 18:40:24 +0100 Subject: [PATCH] fix: make AUTHOR_REGEX less restrictive --- src/poetry/core/masonry/builders/builder.py | 5 ++--- src/poetry/core/packages/package.py | 4 +--- src/poetry/core/utils/patterns.py | 2 ++ tests/packages/test_package.py | 8 +++----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/poetry/core/masonry/builders/builder.py b/src/poetry/core/masonry/builders/builder.py index 9f569299e..ee39c2820 100644 --- a/src/poetry/core/masonry/builders/builder.py +++ b/src/poetry/core/masonry/builders/builder.py @@ -1,7 +1,6 @@ from __future__ import annotations import logging -import re import sys import warnings @@ -9,13 +8,13 @@ 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[- .,\w\d'’\"()]+) <(?P.+?)>$") - METADATA_BASE = """\ Metadata-Version: 2.1 Name: {name} diff --git a/src/poetry/core/packages/package.py b/src/poetry/core/packages/package.py index 1651ca6b6..77c18ec1d 100644 --- a/src/poetry/core/packages/package.py +++ b/src/poetry/core/packages/package.py @@ -1,7 +1,6 @@ from __future__ import annotations import copy -import re from contextlib import contextmanager from pathlib import Path @@ -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 @@ -32,8 +32,6 @@ T = TypeVar("T", bound="Package") -AUTHOR_REGEX = re.compile(r"(?u)^(?P[- .,\w\d'’\"():&]+)(?: <(?P.+?)>)?$") - class Package(PackageSpecification): AVAILABLE_PYTHONS = { diff --git a/src/poetry/core/utils/patterns.py b/src/poetry/core/utils/patterns.py index c2d9d9bfb..c43bb28eb 100644 --- a/src/poetry/core/utils/patterns.py +++ b/src/poetry/core/utils/patterns.py @@ -3,6 +3,8 @@ import re +AUTHOR_REGEX = re.compile(r"(?u)^(?P[^<>]+)(?: <(?P.+?)>)?$") + wheel_file_re = re.compile( r"""^(?P(?P.+?)(-(?P\d.+?))?) ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) diff --git a/tests/packages/test_package.py b/tests/packages/test_package.py index 998b25e22..999e221f5 100644 --- a/tests/packages/test_package.py +++ b/tests/packages/test_package.py @@ -83,6 +83,7 @@ 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), ], ) def test_package_authors_valid(name: str, email: str | None) -> None: @@ -101,12 +102,9 @@ def test_package_authors_valid(name: str, email: str | None) -> None: ("name",), [ ("",), - ("john@john.doe",), + ("",), (" None: