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

AttributeError caused by author field, breaking poetry build #370

Closed
3 tasks done
nackjicholson opened this issue Aug 4, 2018 · 9 comments
Closed
3 tasks done

AttributeError caused by author field, breaking poetry build #370

nackjicholson opened this issue Aug 4, 2018 · 9 comments
Labels
kind/bug Something isn't working as expected

Comments

@nackjicholson
Copy link

  • 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).

Issue

poetry build -f sdist

With author field in pyproject.toml

authors = ["R&D <researchanddevelopment@example.com>"]

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 <researchanddevelopment@example.com>"]

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

@kam1sh
Copy link
Contributor

kam1sh commented Mar 15, 2019

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

Changed to authors = ["Example support <support@example.com>"], works fine.

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

@kam1sh
Copy link
Contributor

kam1sh commented Mar 28, 2019

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

@kam1sh
Copy link
Contributor

kam1sh commented Apr 8, 2019

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

@drunkwcodes
Copy link

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.

,
.
’
()
-

&
@ 
# 

™
®
㊣
↗
↙

@drunkwcodes
Copy link

drunkwcodes commented Apr 8, 2019

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&d@example.com>')
Out[2]: ('R&D', 'r&d@example.com')

In [3]: parseaddr('R#D <r#d@example.com>')
Out[3]: ('R#D', 'r#d@example.com')

In [4]: parseaddr('R()D <r()d@example.com>')
Out[4]: ('R D ( )', 'rd@example.com')

In [5]: parseaddr('R@D <r@d@example.com>')
Out[5]: ('', 'R@D')

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

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.

yggi49 added a commit to yggi49/poetry that referenced this issue Apr 16, 2019
Instead of relying on regular expressions, this patch leverages Python’s
builtin `email.utils.parseaddr()` functionality to parse an RFC-822-compliant
email address string into its name and address parts.

This should also resolve issues with special characters in the name part; see
issues python-poetry#370 and python-poetry#798.

python-poetry#370
python-poetry#798
@brettatoms
Copy link

brettatoms commented Apr 24, 2019

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 <me@example.com"

@brycedrennan brycedrennan added the kind/bug Something isn't working as expected label Aug 15, 2019
@stale
Copy link

stale bot commented Nov 13, 2019

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.

@stale stale bot added the stale label Nov 13, 2019
@stale
Copy link

stale bot commented Nov 20, 2019

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.

@stale stale bot closed this as completed Nov 20, 2019
yggi49 added a commit to yggi49/poetry-core that referenced this issue Nov 12, 2022
Instead of relying on regular expressions, this patch leverages Python’s
builtin `email.utils.parseaddr()` functionality to parse an RFC-822-compliant
email address string into its name and address parts.

This should also resolve issues with special characters in the name
part; see for example Poetry issues python-poetry#370 and #798.

python-poetry/poetry#370
python-poetry/poetry#798
Copy link

github-actions bot commented Mar 3, 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 3, 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

5 participants