Skip to content

Author name validation doesn't allow for "&" in last name #3485

Closed
@ShayNehmad-RecoLabs

Description

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Ubuntu 20.04
  • Poetry version: Poetry version 1.1.4
  • Link of a Gist with the contents of your pyproject.toml file: only the "author" field is relevant

Issue

Hi!
We're using poetry in my R&D group. The "author" of packages in our case is not a specific person but the group, so I've set the author field in the pyproject file to:

[tool.poetry]
# OMITTED...
authors = ["MyCompanyName R&D <rnd@MyCompanyName.MyTLD>"]

(obviously, instead of MyCompaneName I filled in the actual company name)

Stack trace (relevant part):

  3  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/masonry/builders/builder.py:89 in __init__
       87│         )
       88│
    →  89│         self._meta = Metadata.from_package(self._package)
       90│
       91│     @property

  2  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/masonry/metadata.py:54 in from_package
      52│         meta.keywords = ",".join(package.keywords)
      53│         meta.home_page = package.homepage or package.repository_url
    → 54│         meta.author = package.author_name
      55│         meta.author_email = package.author_email
      56│

  1  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/package.py:157 in author_name
      155│     @property
      156│     def author_name(self):  # type: () -> str
    → 157│         return self._get_author()["name"]
      158│
      159│     @property

  ValueError

  Invalid author string. Must be in the format: John Smith <john@example.com>

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/package.py:186 in _get_author
      182│
      183│         m = AUTHOR_REGEX.match(self._authors[0])
      184│
      185│         if m is None:
    → 186│             raise ValueError(
      187│                 "Invalid author string. Must be in the format: "
      188│                 "John Smith <john@example.com>"
      189│             )
      190│

However, when changing the author string to not include the & character (replaced with n), it works.

I think that removing this validation will be helpful.

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions