@@ -1975,11 +1975,7 @@ def file_changed(filename: str, new_contents: str) -> bool:
19751975 return True
19761976
19771977
1978- def write_file (filename : str , new_contents : str , force = False ):
1979- if not force and not file_changed (filename , new_contents ):
1980- # no change: avoid modifying the file modification time
1981- return
1982-
1978+ def write_file (filename : str , new_contents : str ):
19831979 # Atomic write using a temporary file and os.replace()
19841980 filename_new = f"{ filename } .new"
19851981 with open (filename_new , "w" , encoding = "utf-8" ) as fp :
@@ -2241,11 +2237,12 @@ def parse_file(filename, *, verify=True, output=None):
22412237 clinic = Clinic (language , verify = verify , filename = filename )
22422238 src_out , clinic_out = clinic .parse (raw )
22432239
2244- # If clinic output changed, force updating the source file as well.
2245- force = any (file_changed (fn , data ) for fn , data in clinic_out )
2246- write_file (output , src_out , force = force )
2247- for fn , data in clinic_out :
2248- write_file (fn , data )
2240+ changes = [(fn , data ) for fn , data in clinic_out if file_changed (fn , data )]
2241+ if changes :
2242+ # Always (re)write the source file.
2243+ write_file (output , src_out )
2244+ for fn , data in clinic_out :
2245+ write_file (fn , data )
22492246
22502247
22512248def compute_checksum (input , length = None ):
0 commit comments