Chaptered Walkthrough: Deprecating One Function, End to End

This page is written as the script for a short screen-recording walkthrough, laid out by chapter so you can jump to the part you need. There is no video here; the text is the whole thing. The scenario is illustrative: a library called Package A has a function fetchAll() that loads everything into memory, and the maintainers want users to move to a streaming iterate() instead.

Chapter 1: Ship the replacement first

Never deprecate something without a working alternative already released. In Package A, iterate() goes out in a minor version, documented and tested, before anything is marked deprecated. Users should be able to migrate on the same day they first see the warning. If the replacement is still experimental, wait.

Chapter 2: Mark it where editors will notice

The cheapest, most effective signal is the one that shows up as a strikethrough in the user's editor. Each language has its own convention.

// JavaScript / TypeScript
/**
 * @deprecated Use iterate() instead. Will be removed in 5.0.0.
 */
export function fetchAll(query) { /* ... */ }

# Python 3.13+ (also available via typing_extensions)
from warnings import deprecated

@deprecated("Use iterate() instead; removal planned for 5.0.0")
def fetch_all(query): ...

// Go: a paragraph starting with "Deprecated:" in the doc comment
// FetchAll loads every result.
//
// Deprecated: Use Iterate instead.
func FetchAll(q Query) ([]Row, error) { ... }

Type checkers and many linters read these markers, so users get the warning at development time without running anything.

Chapter 3: Add a runtime warning, carefully

Static markers miss people who do not use an editor with type information. A runtime warning catches them, but noisy warnings get disabled, so emit it once per process rather than on every call. In Python, use the warning category deliberately: DeprecationWarning is hidden by default outside of tests and __main__, which suits warnings aimed at developers, while FutureWarning is shown to end users. In Node.js, util.deprecate() handles the once-only behaviour for you.

Chapter 4: Tell people in writing

Add a "Deprecated" entry to the changelog for the minor release, naming the replacement and the planned removal version. Update the documentation page for fetchAll() with a banner pointing at iterate(), and include a short migration example. If the library has a migration guide for the next major, start it now and add this item to it.

Chapter 5: Measure, then wait

Search public code hosts and your own issue tracker for usage of the old function to get a rough sense of how widely it is used. If adoption of the replacement is slow, that is a signal to improve the migration docs, not to remove the function sooner. Keep to the notice period your project has published.

Chapter 6: Remove it in the major

In 5.0.0, delete fetchAll(), its tests and its documentation page, leaving a short note in the docs that redirects to iterate(). The changelog's "Removed" section lists it with a one-line migration hint. Because removal is a breaking change, it never lands in a minor or patch release.

Recap checklist

Related pages