question 483 Application Delivery · easy
Review a lock file upgrade
A pull request regenerates requirements.lock. Reviewers want a short list of what changed, with downgrades called out, because a downgrade is often an accident. Compare the old and new pins.
Function
lock_changes(old, new); both map package name to a version like "2.10.0" (whole numbers separated by dots)Returnssorted lines:
"added <name> <v>", "removed <name> <v>", "upgraded <name> <a> -> <b>", "downgraded <name> <a> -> <b>"; unchanged packages are left outComparingversions compare as numbers, part by part:
2.10.0 is newer than 2.9.4Examples
calllock_changes({'numpy': '2.1.3', 'pandas': '2.2.3', 'six': '1.17.0'}, {'numpy': '2.1.2', 'pandas': '2.2.10', 'tzdata': '2025.1'})returns['added tzdata 2025.1', 'downgraded numpy 2.1.3 -> 2.1.2', 'removed six 1.17.0', 'upgraded pandas 2.2.3 -> 2.2.10']
calllock_changes({'attrs': '24.2.0'}, {'attrs': '24.2.0'})returns[]
calllock_changes({}, {'rich': '13.9.4'})returns['added rich 13.9.4']