33Fix all remaining issues in the graph algorithms PR.
44Run from repo root.
55"""
6+
67from pathlib import Path
78
89
@@ -11,7 +12,9 @@ def fix_chinese_postman():
1112 text = p .read_text ()
1213
1314 # Only add -> None to __init__
14- text = text .replace ('def __init__(self, n: int):' , 'def __init__(self, n: int) -> None:' )
15+ text = text .replace (
16+ "def __init__(self, n: int):" , "def __init__(self, n: int) -> None:"
17+ )
1518
1619 p .write_text (text )
1720 print ("fixed chinese_postman.py" )
@@ -21,7 +24,9 @@ def fix_ford_fulkerson():
2124 p = Path ("graphs/ford_fulkerson.py" )
2225 text = p .read_text ()
2326
24- text = text .replace ('def __init__(self, n: int):' , 'def __init__(self, n: int) -> None:' )
27+ text = text .replace (
28+ "def __init__(self, n: int):" , "def __init__(self, n: int) -> None:"
29+ )
2530
2631 p .write_text (text )
2732 print ("fixed ford_fulkerson.py" )
@@ -31,7 +36,7 @@ def fix_floyd_warshall():
3136 p = Path ("graphs/floyd_warshall.py" )
3237 text = p .read_text ()
3338
34- text = text .replace (' def benchmark():' , ' def benchmark() -> None:' )
39+ text = text .replace (" def benchmark():" , " def benchmark() -> None:" )
3540
3641 p .write_text (text )
3742 print ("fixed floyd_warshall.py" )
@@ -41,8 +46,8 @@ def fix_two_sat():
4146 p = Path ("graphs/two_sat.py" )
4247 text = p .read_text ()
4348
44- text = text .replace (' def dfs1(u: int):' , ' def dfs1(u: int) -> None:' )
45- text = text .replace (' def dfs2(u: int):' , ' def dfs2(u: int) -> None:' )
49+ text = text .replace (" def dfs1(u: int):" , " def dfs1(u: int) -> None:" )
50+ text = text .replace (" def dfs2(u: int):" , " def dfs2(u: int) -> None:" )
4651
4752 p .write_text (text )
4853 print ("fixed two_sat.py" )
@@ -53,12 +58,12 @@ def fix_test_graph_algorithms():
5358 text = p .read_text ()
5459
5560 # Fix johnson test expectation
56- text = text .replace (' assert dist[0][4] == -1' , ' assert dist[0][4] == 0' )
61+ text = text .replace (" assert dist[0][4] == -1" , " assert dist[0][4] == 0" )
5762
5863 # Fix codespell: mis -> independent_set
59- text = text .replace (' mis = ' , ' independent_set = ' )
60- text = text .replace (' (mis)' , ' (independent_set)' )
61- text = text .replace (' mis.' , ' independent_set.' )
64+ text = text .replace (" mis = " , " independent_set = " )
65+ text = text .replace (" (mis)" , " (independent_set)" )
66+ text = text .replace (" mis." , " independent_set." )
6267
6368 p .write_text (text )
6469 print ("fixed test_graph_algorithms.py" )
@@ -71,4 +76,4 @@ def fix_test_graph_algorithms():
7176 fix_floyd_warshall ()
7277 fix_two_sat ()
7378 fix_test_graph_algorithms ()
74- print ("\n Done! Now run tests and ruff." )
79+ print ("\n Done! Now run tests and ruff." )
0 commit comments