Poetry: AttributeError caused by author field, breaking `poetry build`

Created on 4 Aug 2018  Â·  8Comments  Â·  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

poetry build -f sdist

With author field in pyproject.toml

authors = ["R&D <[email protected]>"]

Output:

[AttributeError]               
'NoneType' object has no attribute 'group'  

Perhaps this is for a good reason, but it confused me for a long while because I didn't know this meant something was wrong in my pyproject.toml file. It would be useful to have indications of toml validation problems by field.

Changed to:

authors = ["Research Development <[email protected]>"]

Works, and that is fine. Just didn't know there were validation rules for these strings.

Bug stale

Most helpful comment

@nackjicholson What do you think, maybe replacing 'NoneType' object has no attribute 'group' to Invalid project's author: "author ([email protected])" would be enough?

All 8 comments

Faced this problem today, on version 0.12.11 (Python 3.7.2). Had this field in pyproject.toml:
authors = ["[email protected]]

Changed to authors = ["Example support <[email protected]>"], works fine.

I'll try to fix this on this or next weekend, because it looks like obvious regex mismatch.

@nackjicholson What do you think, maybe replacing 'NoneType' object has no attribute 'group' to Invalid project's author: "author ([email protected])" would be enough?

Well... my PR got softly rejected, but you or someone else could find some useful solutions among my commits =/

Thanks, @kam1sh.

The problem is '&' mismatched in AUTHOR_REGEX.

Here are some common punctuation marks in names.
I would like to make a PR to add them into regex with test cases if the list has no issue.

,
.
’
()
-

&
@ 
# 

â„¢
®
㊣
↗
↙

And I thought this is a good place to discuss introducing email lib.
It handles arbitrary marks so well in the case of formal email form.

Here are example results with inputs listed above:

In [1]: from email.utils import parseaddr

In [2]: parseaddr('R&D <r&[email protected]>')
Out[2]: ('R&D', 'r&[email protected]')

In [3]: parseaddr('R#D <r#[email protected]>')
Out[3]: ('R#D', 'r#[email protected]')

In [4]: parseaddr('R()D <r()[email protected]>')
Out[4]: ('R D ( )', '[email protected]')

In [5]: parseaddr('R@D <r@[email protected]>')
Out[5]: ('', 'R@D')

In [7]: parseaddr('RDâ„¢ <[email protected]>')
Out[7]: ('RDâ„¢', '[email protected]')

In [8]: parseaddr('RD㊣ <rd㊣@example.com>')
Out[8]: ('RD㊣', 'rd㊣@example.com')

In [9]: parseaddr('↙R&D↗ <↙rd↗@example.com>')
Out[9]: ('↙R&D↗', '↙rd↗@example.com')

Not supporting parentheses is the only concern to change to use parseaddr.

You get the same error as well if the author string isn't formatted correctly, e.g. if the closing bracket is missing like "Me <[email protected]"

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexlatchford picture alexlatchford  Â·  3Comments

ulope picture ulope  Â·  3Comments

nikaro picture nikaro  Â·  3Comments

jhrmnn picture jhrmnn  Â·  3Comments

sobolevn picture sobolevn  Â·  3Comments