@@ -95,8 +95,13 @@ class BlurbError(RuntimeError):
9595
9696
9797class Blurbs (list ):
98- def parse (self , text : str , * , metadata : dict [str , str ] | None = None ,
99- filename : str = 'input' ) -> None :
98+ def parse (
99+ self ,
100+ text : str ,
101+ * ,
102+ metadata : dict [str , str ] | None = None ,
103+ filename : str = 'input' ,
104+ ) -> None :
100105 """Parses a string.
101106
102107 Appends a list of blurb ENTRIES to self, as tuples: (metadata, body)
@@ -147,13 +152,17 @@ def finish_entry() -> None:
147152 throw (f'Invalid { issue_keys [key ]} number: { value !r} ' )
148153
149154 if key == 'gh-issue' and int (value ) < lowest_possible_gh_issue_number :
150- throw (f'Invalid gh-issue number: { value !r} (must be >= { lowest_possible_gh_issue_number } )' )
155+ throw (
156+ f'Invalid gh-issue number: { value !r} (must be >= { lowest_possible_gh_issue_number } )'
157+ )
151158
152159 if key == 'section' :
153160 if no_changes :
154161 continue
155162 if value not in sections :
156- throw (f'Invalid section { value !r} ! You must use one of the predefined sections.' )
163+ throw (
164+ f'Invalid section { value !r} ! You must use one of the predefined sections.'
165+ )
157166
158167 if 'gh-issue' not in metadata and 'bpo' not in metadata :
159168 throw ("'gh-issue:' or 'bpo:' must be specified in the metadata!" )
@@ -232,7 +241,9 @@ def _parse_next_filename(filename: str) -> dict[str, str]:
232241 assert section in sections , f'Unknown section { section } '
233242
234243 fields = [x .strip () for x in filename .split ('.' )]
235- assert len (fields ) >= 4 , f"Can't parse 'next' filename! filename { filename !r} fields { fields } "
244+ assert len (fields ) >= 4 , (
245+ f"Can't parse 'next' filename! filename { filename !r} fields { fields } "
246+ )
236247 assert fields [- 1 ] == 'rst'
237248
238249 metadata = {'date' : fields [0 ], 'nonce' : fields [- 2 ], 'section' : section }
@@ -263,7 +274,7 @@ def ensure_metadata(self) -> None:
263274 ('bpo' , '0' ),
264275 ('date' , sortable_datetime ()),
265276 ('nonce' , generate_nonce (body )),
266- ):
277+ ):
267278 if name not in metadata :
268279 metadata [name ] = default
269280
@@ -274,10 +285,14 @@ def _extract_next_filename(self) -> str:
274285 metadata ['section' ] = sanitize_section (metadata ['section' ])
275286 metadata ['root' ] = root
276287 if int (metadata ['gh-issue' ]) > 0 :
277- path = '{root}/Misc/NEWS.d/next/{section}/{date}.gh-issue-{gh-issue}.{nonce}.rst' .format_map (metadata )
288+ path = '{root}/Misc/NEWS.d/next/{section}/{date}.gh-issue-{gh-issue}.{nonce}.rst' .format_map (
289+ metadata
290+ )
278291 elif int (metadata ['bpo' ]) > 0 :
279292 # assume it's a GH issue number
280- path = '{root}/Misc/NEWS.d/next/{section}/{date}.bpo-{bpo}.{nonce}.rst' .format_map (metadata )
293+ path = '{root}/Misc/NEWS.d/next/{section}/{date}.bpo-{bpo}.{nonce}.rst' .format_map (
294+ metadata
295+ )
281296 for name in ('root' , 'section' , 'date' , 'gh-issue' , 'bpo' , 'nonce' ):
282297 del metadata [name ]
283298 return path
@@ -294,4 +309,4 @@ def save_next(self) -> str:
294309
295310
296311def sortable_datetime () -> str :
297- return time .strftime (" %Y-%m-%d-%H-%M-%S" , time .localtime ())
312+ return time .strftime (' %Y-%m-%d-%H-%M-%S' , time .localtime ())
0 commit comments