24
24
from pep_sphinx_extensions .pep_zero_generator .errors import PEPError
25
25
26
26
if TYPE_CHECKING :
27
- from pep_sphinx_extensions .pep_zero_generator .author import Author
28
- from pep_sphinx_extensions .pep_zero_generator .parser import PEP
27
+ from pep_sphinx_extensions .pep_zero_generator .parser import PEP
29
28
30
29
title_length = 55
31
30
author_length = 40
@@ -195,15 +194,15 @@ def write_pep0(self, peps: list[PEP]):
195
194
196
195
# PEP owners
197
196
authors_dict = _verify_email_addresses (peps )
198
- max_name_len = max (len (author . last_first ) for author in authors_dict . keys () )
197
+ max_name_len = max (len (author_name ) for author_name in authors_dict )
199
198
self .emit_title ("Authors/Owners" , "authors" )
200
199
self .emit_author_table_separator (max_name_len )
201
200
self .emit_text (f"{ 'Name' :{max_name_len }} Email Address" )
202
201
self .emit_author_table_separator (max_name_len )
203
- for author in _sort_authors (authors_dict ):
202
+ for author_name in _sort_authors (authors_dict ):
204
203
# Use the email from authors_dict instead of the one from "author" as
205
204
# the author instance may have an empty email.
206
- self .emit_text (f"{ author . last_first :{max_name_len }} { authors_dict [author ]} " )
205
+ self .emit_text (f"{ author_name :{max_name_len }} { authors_dict [author_name ]} " )
207
206
self .emit_author_table_separator (max_name_len )
208
207
self .emit_newline ()
209
208
self .emit_newline ()
@@ -268,27 +267,27 @@ def _classify_peps(peps: list[PEP]) -> tuple[list[PEP], ...]:
268
267
return meta , info , provisional , accepted , open_ , finished , historical , deferred , dead
269
268
270
269
271
- def _verify_email_addresses (peps : list [PEP ]) -> dict [Author , str ]:
272
- authors_dict : dict [Author , set [str ]] = {}
270
+ def _verify_email_addresses (peps : list [PEP ]) -> dict [str , str ]:
271
+ authors_dict : dict [str , set [str ]] = {}
273
272
for pep in peps :
274
273
for author in pep .authors :
275
274
# If this is the first time we have come across an author, add them.
276
- if author not in authors_dict :
277
- authors_dict [author ] = { author . email } if author . email else set ()
278
- else :
279
- # If the new email is an empty string, move on.
280
- if not author .email :
281
- continue
282
- # If the email has not been seen, add it to the list.
283
- authors_dict [author ].add (author .email )
284
-
285
- valid_authors_dict = {}
286
- too_many_emails = []
287
- for author , emails in authors_dict .items ():
275
+ if author . last_first not in authors_dict :
276
+ authors_dict [author . last_first ] = set ()
277
+
278
+ # If the new email is an empty string, move on.
279
+ if not author .email :
280
+ continue
281
+ # If the email has not been seen, add it to the list.
282
+ authors_dict [author . last_first ].add (author .email )
283
+
284
+ valid_authors_dict : dict [ str , str ] = {}
285
+ too_many_emails : list [ tuple [ str , set [ str ]]] = []
286
+ for last_first , emails in authors_dict .items ():
288
287
if len (emails ) > 1 :
289
- too_many_emails .append ((author . last_first , emails ))
288
+ too_many_emails .append ((last_first , emails ))
290
289
else :
291
- valid_authors_dict [author ] = next (iter (emails ), "" )
290
+ valid_authors_dict [last_first ] = next (iter (emails ), "" )
292
291
if too_many_emails :
293
292
err_output = []
294
293
for author , emails in too_many_emails :
@@ -301,13 +300,13 @@ def _verify_email_addresses(peps: list[PEP]) -> dict[Author, str]:
301
300
return valid_authors_dict
302
301
303
302
304
- def _sort_authors (authors_dict : dict [Author , str ]) -> list [Author ]:
305
- return sorted (authors_dict . keys () , key = _author_sort_by )
303
+ def _sort_authors (authors_dict : dict [str , str ]) -> list [str ]:
304
+ return sorted (authors_dict , key = _author_sort_by )
306
305
307
306
308
- def _author_sort_by (author : Author ) -> str :
307
+ def _author_sort_by (author_name : str ) -> str :
309
308
"""Skip lower-cased words in surname when sorting."""
310
- surname , * _ = author . last_first .split ("," )
309
+ surname , * _ = author_name .split ("," )
311
310
surname_parts = surname .split ()
312
311
for i , part in enumerate (surname_parts ):
313
312
if part [0 ].isupper ():
0 commit comments