Semantic Versioning Signals Breaking Changes Through the Major Number

In progress

Semantic versioning (semver) gives each part of a MAJOR.MINOR.PATCH number a meaning, so a version change tells users how risky an upgrade is before they read the changelog. Dependency constraints rely on that promise: they let patch and minor upgrades in automatically and hold back the major ones.

What Each Number Means

Part Bumped when Upgrade risk
MAJOR (X) an incompatible change: your code may need edits review before upgrading
MINOR (Y) new, backward-compatible features low
PATCH (Z) backward-compatible bug fixes, often security fixes lowest: apply promptly

Before 1.0.0, anything may change at any time: a 0.y minor bump can break things.

Pinning Strategies

poetry add django==4.2.2      # exact: only that version
poetry add "django@^4.2"      # caret: >=4.2.0,<5.0.0, follows minors and patches
poetry add "django@~4.2.2"    # tilde: >=4.2.2,<4.3.0, patches only

References

Review cards

Flashcard Why does the major version number in semantic versioning indicate a high upgrade risk?

Because a major version bump signals an incompatible change that may require modifications to your code.

Quiz Which of the following dependency specification strategies in Poetry allows for minor and patch updates but not major updates?
  • poetry add django==4.2.2
  • poetry add 'django@^4.2'
  • poetry add 'django@~4.2.2'
  • poetry add 'django@4.2'

The caret symbol (^) in Poetry specifies a range that includes minor and patch updates but excludes major updates.