Lesson 4 of 9 · 18m
Semantic Versioning in Practice
What SemVer promises, how Python pre-releases work, and the breaking changes maintainers ship by accident.
Semantic Versioning looks simple — major.minor.patch — until you have users. Then it becomes a compatibility promise. The version number is communication infrastructure: it tells downstream teams how much attention an upgrade deserves before they ever read the changelog.
The contract
MAJOR incompatible API changes
MINOR backward-compatible features
PATCH backward-compatible fixesFor Python libraries, the API is broader than function signatures. Public module names, class hierarchies, exceptions users catch, CLI flags, entry point names, file formats, and documented behavior are all part of the surface. Removing an unused-looking argument can be breaking. Changing an exception type can be breaking. Making an async function sync is definitely breaking.
Python versions have precise ordering
1.2.0a1 < 1.2.0b1 < 1.2.0rc1 < 1.2.0 < 1.2.0.post1Pre-releases are not installed by default. pip install acme-metrics==1.2.0rc1 works, but a bare install won't select it unless there is no stable alternative. Use release candidates for real integration testing, not as a permanent hiding place for unstable releases.
Deprecate before deleting
A mature breaking-change path looks like this:
import warnings
def fetch(url, timeout=None, *, max_wait=None):
if timeout is not None:
warnings.warn(
"timeout is deprecated; use max_wait",
DeprecationWarning,
stacklevel=2,
)
max_wait = timeoutShip the deprecation in a minor release, document the migration, and remove the old behavior only in the next major. Remember that Python hides DeprecationWarning in many contexts; library maintainers often use FutureWarning when end users need to see it.
Versioning policy beats version numbers
Write down what is forums. A leading underscore means private by convention, but users will still import it if it solves their problem. An explicit __all__, documentation boundary, and changelog make the promise enforceable.
Field notes
0.xversions communicate instability, but they do not excuse careless breakage once organizations depend on you.- A patch release that adds a new dependency can still break users; compatibility includes packaging constraints.
- Keep a changelog humans can scan. Generated commit dumps are not release notes.
- Yanked releases are for dangerous artifacts, not routine mistakes; version numbers are cheap, trust is expensive.
Was this lesson helpful?