nit: the diff-friendly format shouldn't be all indented like this as you'd have to re-indent every subsequent line if the first line changed for some reason (similar reasoning for not lining up assignment operators).

```python
link.selftext = template % {
    "old-name": old_name,
    ...
}
```