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

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

Closed
3 tasks done
ShayNehmad-RecoLabs opened this issue Dec 13, 2020 · 3 comments
Closed
3 tasks done

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

ShayNehmad-RecoLabs opened this issue Dec 13, 2020 · 3 comments
Labels
kind/bug Something isn't working as expected

Comments

@ShayNehmad-RecoLabs
Copy link

ShayNehmad-RecoLabs commented Dec 13, 2020

  • 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 <[email protected]>"]

(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 <[email protected]>

  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 <[email protected]>"
      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.

@ShayNehmad-RecoLabs ShayNehmad-RecoLabs added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 13, 2020
@8F3E
Copy link
Contributor

8F3E commented Dec 22, 2020

Not sure if there's any technical reason why & shouldn't be used, but it seems adding it into the regex on line 20 of https://github.com/python-poetry/poetry-core/blob/master/poetry/core/packages/package.py should fix the issue.

ShayNehmad-RecoLabs added a commit to ShayNehmad-RecoLabs/poetry-core that referenced this issue Dec 27, 2020
finswimmer pushed a commit to python-poetry/poetry-core that referenced this issue Jan 25, 2021
@ShayNehmad-RecoLabs
Copy link
Author

Merged in python-poetry/poetry-core#120! Thanks @finswimmer

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants