Sub topic 17
After release: yanking, deprecation, and changelogs
This chapter assumes you have already published greeter to PyPI, understand PEP 440 versions, and can build and upload with build and twine. Once a release is public, you can't edit it. This chapter covers how to respond when a release turns out to be faulty, and how to tell users what changed.
Why you cannot delete or replace a release
PyPI does not let you re-upload a file under a filename it has already seen, even after you delete it. Mirrors and caches may also hold copies. Once greeter 0.1.0 is published, that version number is permanently used. Every fix therefore ships as a new version.
Yanking a bad release
Yanking (PEP 592) marks a release as "do not install this unless someone asks for it by exact version". The files stay available, so pinned installs such as greeter==0.1.0 still work. Installers skip a yanked release when resolving a range such as greeter>=0.1 or greeter.
To yank, open the project's release page on PyPI, choose Options, then Yank, and give a reason. pip shows the reason when someone installs the release by exact pin. You can un-yank the release later if you yank by mistake.
Use yanking when a release is broken, for example it crashes on import or has a wrong requires-python bound. Don't use it just because a newer version exists.
Shipping the fix
After yanking, repeat the normal release steps with a new version. A bug fix with no API change is a patch bump, so 0.1.0 becomes 0.1.1. Change the version only in pyproject.toml, since __version__ reads it from the installed metadata.
Deprecating a feature
Removing a public function without warning breaks users. Deprecate it first: keep it working, emit a warning, and remove it in a later release that you announce as breaking.
# src/greeter/__init__.py (excerpt)
import warnings
def greet_user(name: str) -> str:
warnings.warn(
"greet_user() is deprecated and will be removed in 1.0; use greet().",
DeprecationWarning,
stacklevel=2,
)
return greet(name)stacklevel=2 makes the warning point at the caller's line instead of your library's. Python hides DeprecationWarning by default outside __main__ and test runners, so tell users to run tests with python -W error::DeprecationWarning or use pytest, which shows them.
Keeping a changelog
A changelog tells users what changed between versions, so they can decide whether to upgrade. Keep a CHANGELOG.md in the repository, newest release first, with an "Unreleased" section on top.
# Changelog
## Unreleased
## 0.1.1 - 2026-11-26
### Fixed
- Fixed an import error that made 0.1.0 unusable. 0.1.0 is yanked.
## 0.1.0 - 2026-11-20
### Added
- First release with `greet()` and the `greeter` command.Group entries under headings such as Added, Changed, Deprecated, Removed, and Fixed. Note yanked versions in the entry for the release that replaces them.
Exercise
Version 1.2.0 of your library crashes on import. Users who wrote mylib>=1.0 are affected. What two steps fix this for them, and why is deleting 1.2.0 not an option?
Show answer
Yank 1.2.0 so resolvers stop selecting it, then publish 1.2.1 with the fix, which makes mylib>=1.0 resolve to 1.2.1. PyPI never lets a filename be reused, so a corrected 1.2.0 cannot be uploaded, and a new version number is required.