Skip to content

Commit a7d6994

Browse files
committed
Allow authors to use different email addresses in different PEPs
The context here is that Yury Selivanov and I have a forthcoming PEP and would prefer to use our current employer's email addresses for it, but don't want to change our email addresses on earlier PEPs we've written. (Obviously this affects more PEPs for Yury than for me :P) There's no serious technical impediment to supporting this, so I have. I've tested this locally.
1 parent c4d6770 commit a7d6994

File tree

1 file changed

+10
-21
lines changed
  • pep_sphinx_extensions/pep_zero_generator

1 file changed

+10
-21
lines changed

pep_sphinx_extensions/pep_zero_generator/writer.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -331,36 +331,25 @@ def _classify_peps(peps: list[PEP]) -> tuple[list[PEP], ...]:
331331

332332

333333
def _verify_email_addresses(peps: list[PEP]) -> dict[str, str]:
334-
authors_dict: dict[str, set[str]] = {}
334+
authors_dict: dict[str, list[str]] = {}
335335
for pep in peps:
336336
for author in pep.authors:
337337
# If this is the first time we have come across an author, add them.
338338
if author.full_name not in authors_dict:
339-
authors_dict[author.full_name] = set()
339+
authors_dict[author.full_name] = []
340340

341341
# If the new email is an empty string, move on.
342342
if not author.email:
343343
continue
344344
# If the email has not been seen, add it to the list.
345-
authors_dict[author.full_name].add(author.email)
346-
347-
valid_authors_dict: dict[str, str] = {}
348-
too_many_emails: list[tuple[str, set[str]]] = []
349-
for full_name, emails in authors_dict.items():
350-
if len(emails) > 1:
351-
too_many_emails.append((full_name, emails))
352-
else:
353-
valid_authors_dict[full_name] = next(iter(emails), "")
354-
if too_many_emails:
355-
err_output = []
356-
for author, emails in too_many_emails:
357-
err_output.append(" " * 4 + f"{author}: {emails}")
358-
raise ValueError(
359-
"some authors have more than one email address listed:\n"
360-
+ "\n".join(err_output)
361-
)
362-
363-
return valid_authors_dict
345+
emails = authors_dict[author.full_name]
346+
if author.email not in emails:
347+
emails.append(author.email)
348+
349+
# Combine multiple email addresses with commas. Since peps is
350+
# sorted by PEP number, this should produce a deterministic
351+
# output.
352+
return {name: ', '.join(emails) for name, emails in authors_dict.items()}
364353

365354

366355
def _sort_authors(authors_dict: dict[str, str]) -> list[str]:

0 commit comments

Comments
 (0)