File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 88
99from __future__ import annotations
1010
11+ import sys
12+
1113from pathlib import Path
14+ from typing import Any
15+
16+
17+ if sys .version_info < (3 , 10 ):
18+
19+ def _newline_write_text (path : Path , content : str , ** kwargs : Any ) -> None :
20+ with path .open ("w" , ** kwargs ) as strm :
21+ strm .write (content )
22+
23+ else :
24+
25+ def _newline_write_text (path : Path , content : str , ** kwargs : Any ) -> None :
26+ path .write_text (content , ** kwargs )
1227
1328
1429def append_to_newsfile (
@@ -37,7 +52,8 @@ def append_to_newsfile(
3752 if top_line and top_line in prev_body :
3853 raise ValueError ("It seems you've already produced newsfiles for this version?" )
3954
40- news_file .write_text (
55+ _newline_write_text (
56+ news_file ,
4157 # If there is no previous body that means we're writing a brand new news file.
4258 # We don't want extra whitespace at the end of this new file.
4359 header + (content + prev_body if prev_body else content .rstrip () + "\n " ),
You can’t perform that action at this time.
0 commit comments