Skip to content

Commit

Permalink
Use email.headerregistry.Address to format 'name <email@domain>'
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Mar 12, 2021
1 parent 88dde16 commit 43b7c54
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
@@ -1,4 1,5 @@
import difflib
from email.headerregistry import Address
import errno
import logging
import os
Expand Down Expand Up @@ -606,7 607,7 @@ def pep621_people(people, group_name='author') -> dict:
if 'email' in person:
email = person['email']
if 'name' in person:
email = '{} <{}>'.format(person["name"], email)
email = str(Address(person['name'], addr_spec=email))
emails.append(email)
elif 'name' in person:
names.append(person['name'])
Expand Down
2 changes: 1 addition & 1 deletion flit_core/flit_core/tests/samples/pep621/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,7 @@ build-backend = "flit_core.buildapi"
[project]
name = "module1"
authors = [
{name = "Sir Robin", email = "[email protected]"}
{name = "Sir Röbin", email = "[email protected]"}
]
maintainers = [
{name = "Sir Galahad"}
Expand Down
2 changes: 1 addition & 1 deletion flit_core/flit_core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@ def test_load_pep621():
assert inf.metadata['name'] == 'module1'
assert inf.metadata['description_content_type'] == 'text/x-rst'
assert inf.metadata['requires_dist'] == ["requests >= 2.18", "docutils"]
assert inf.metadata['author_email'] == "Sir Robin <[email protected]>"
assert inf.metadata['author_email'] == "Sir Röbin <[email protected]>"
assert inf.entrypoints['flit_test_example']['foo'] == 'module1:main'
assert set(inf.dynamic_metadata) == {'version', 'description'}

Expand Down

0 comments on commit 43b7c54

Please sign in to comment.