Skip to content

Commit 71cc0e5

Browse files
committed
More intuitive metadata when not all authors/maintainers have email addresses
1 parent e7c4239 commit 71cc0e5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

flit_core/flit_core/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ def name_is_valid(name) -> bool:
783783
def pep621_people(people, group_name='author') -> dict:
784784
"""Convert authors/maintainers from PEP 621 to core metadata fields"""
785785
names, emails = [], []
786+
names_without_emails = False
786787
for person in people:
787788
if not isinstance(person, dict):
788789
raise ConfigError("{} info must be list of dicts".format(group_name))
@@ -796,11 +797,15 @@ def pep621_people(people, group_name='author') -> dict:
796797
if 'name' in person:
797798
email = str(Address(person['name'], addr_spec=email))
798799
emails.append(email)
799-
elif 'name' in person:
800+
if 'name' in person:
800801
names.append(person['name'])
802+
if 'email' not in person:
803+
names_without_emails = True
801804

802805
res = {}
803-
if names:
806+
# The -Email fields include names (name <email>), so are preferred if
807+
# everyone in the list provides an email address.
808+
if names_without_emails:
804809
res[group_name] = ", ".join(names)
805810
if emails:
806811
res[group_name + '_email'] = ", ".join(emails)

flit_core/tests_core/samples/pep621/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ authors = [
88
{name = "Sir Röbin", email = "robin@camelot.uk"}
99
]
1010
maintainers = [
11-
{name = "Sir Galahad"}
11+
{name = "Sir Galahad"},
12+
{name = "Sir Bedevere", email = "bedevere@camelot.uk"}
1213
]
1314
readme = "README.rst"
1415
license = {file = "LICENSE"}

flit_core/tests_core/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def test_load_pep621():
3939
'mock;extra=="test"and(python_version<\'3.6\')',
4040
}
4141
assert inf.metadata['author_email'] == "Sir Röbin <robin@camelot.uk>"
42+
assert 'author' not in inf.metadata # Skipped in favour of author_email
43+
assert inf.metadata['maintainer_email'] == "Sir Bedevere <bedevere@camelot.uk>"
44+
assert inf.metadata['maintainer'] == "Sir Galahad, Sir Bedevere"
4245
assert inf.entrypoints['flit_test_example']['foo'] == 'module1:main'
4346
assert set(inf.dynamic_metadata) == {'version', 'description'}
4447

0 commit comments

Comments
 (0)