@@ -1975,11 +1975,7 @@ def file_changed(filename: str, new_contents: str) -> bool:
1975
1975
return True
1976
1976
1977
1977
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 ):
1983
1979
# Atomic write using a temporary file and os.replace()
1984
1980
filename_new = f"{ filename } .new"
1985
1981
with open (filename_new , "w" , encoding = "utf-8" ) as fp :
@@ -2241,11 +2237,12 @@ def parse_file(filename, *, verify=True, output=None):
2241
2237
clinic = Clinic (language , verify = verify , filename = filename )
2242
2238
src_out , clinic_out = clinic .parse (raw )
2243
2239
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 )
2249
2246
2250
2247
2251
2248
def compute_checksum (input , length = None ):
0 commit comments