python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.14k stars 2.25k forks source link

Author Regex Too Restrictive #6933

Open muellert opened 1 year ago

muellert commented 1 year ago

Issue

I am trying to use Poetry in an environment where user names, as per the Gecos field, are structured like 'Surname, Given Name [Department]'. If I run 'poetry new testing-poetry', I get a pyproject.yaml file that has

authors = ["Surname, Given Name [Department]"]

When I now run 'poetry build', this will bomb out with

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

I suggest augmenting the AUTHOR_REGEX, which, in "my" installation (virtualenv) is duplicated in

core/masonry/builders/builder.py and core/package/package.py

to allow for square brackets in the name field of the author.

Jenjen1324 commented 1 year ago

Just as a heads up, one might want to check what restrictions should actually be placed on the author name:

Per PEP621 the authors/maintainers name MUST be a valid email name. It refers to RFC 822, but I found the following SO post which explains what an email name is a bit more clearly: https://stackoverflow.com/a/2049510/2232127 (the post also refers to this nice Wikipedia article: https://en.wikipedia.org/wiki/Email_address#Local-part )

While [] seems to be allowed, they seem to require escaping and explicit quoting when used in an email address. So in general I'd be weary of actually using [] in the author.

muellert commented 1 year ago

The square brackets are not part of the author email, but part of the author name. Also, using or not using them is beyond my sphere of influence because this aspect of naming is managed by the organization, and I have no say in that whatsoever. To recap, what the organization gives me, is of the form

"Last, First [department]" <someid@example.com>

In this example, 'someid' is the local part of the email, but poetry falls over at the square brackets in the 'display-name' field (please refer to RFC 2822, section 3.4). The local part of the email address is perfectly fine and contains no problematic characters.

whinee commented 1 year ago

Hello, I would like to add to this (arguably) dead discussion.

According to the linked wiki article: en.wikipedia.org/wiki/Email_address#Local-part, tilde (~) and exclamation point (!) is allowed in E-mail. But from my testing, it it not allowed in the author's name.

I guess using goofy author names like whi~nyaan! will have the coding gods strike a lighting upon you. But still...