refurb
A tool for refurbishing and modernizing Python codebases
What it is and what it does
Refurb is a linter that identifies opportunities to modernize Python code by suggesting idiomatic rewrites. It runs on Python 3.10+ and uses mypy internally for type analysis, allowing it to detect patterns like unnecessary list literals in membership tests, redundant type casts, and verbose file-handling idioms. The tool emits structured error codes (FURB###) for each suggestion, which can be explained inline, ignored selectively, or configured globally via pyproject.toml.
You run it as a command-line tool on files or directories, and it outputs suggestions in plain text or GitHub Actions format. Checks can be enabled, disabled, or ignored individually or by category, and you can target specific Python versions to ensure suggestions are compatible with your codebase's minimum supported version. It integrates with pre-commit and supports per-file or per-folder configuration overrides.
Use it for:
- Incrementally modernize a legacy Python codebase by running Refurb and selectively applying suggestions per file or folder.
- Enforce code style consistency in CI/CD pipelines by configuring Refurb checks in pyproject.toml and failing builds on violations.
- Learn Python idioms and best practices by using `refurb --explain FURB###` to understand why a particular pattern is recommended.
- Integrate with pre-commit hooks to catch modernization opportunities before code review.
- Target a specific Python version (e.g., 3.10) to ensure all refactoring suggestions are compatible with your minimum supported version.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Refurb is a static analysis tool that scans Python code to identify modernization opportunities and suggest idiomatic rewrites, powered by mypy for type checking.
Yes. Refurb is actively maintained, has no known vulnerabilities, low install friction, and solves a clear problem: identifying and suggesting idiomatic Python rewrites. The copyleft GPL-3.0 license is a consideration for proprietary codebases but not a blocker for open-source projects or internal tools. Recommended for teams seeking to modernize Python code systematically.
Install
refurb on PyPI
pip
pip install refurbuv
uv add refurbpoetry
poetry add refurbInstalling refurb
Before you install
Low install friction with a pure-wheel distribution. Actively maintained as of 2026-04-03 with 2534 repository stars. Requires Python 3.10+ to run, though it can analyze code targeting Python 3.7+.
License in practice
Licensed under GPL-3.0-only (copyleft). Any derivative work or distribution must also be licensed under GPLv3; suitable for internal tools and open-source projects but requires careful consideration in proprietary codebases.
Quickstart
# Install via pipx (recommended for CLI tools)
$ pipx install refurb
# Run on a file or directory
$ refurb main.py
# Output: main.py:3:17 [FURB109]: Use `in (x, y, z)` instead of `in [x, y, z]`
# Explain a specific error code
$ refurb --explain FURB109
Requires Python 3.10+ to run the tool itself, though it can analyze code targeting Python 3.7+ by setting the `--python-version` flag.
Verify before relying
- Whether the tool's checks cover all common modernization patterns or if certain categories of improvements are not yet implemented
- Performance characteristics when analyzing large codebases or deeply nested directory structures
Package facts
| License | GPL-3.0-only (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — mypy, tomli |
| Maintenance | actively maintained — 133 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 93,472/month — #13,384 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: refurb-2.3.1-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
deadcodeScans Python codebases to find and optionally…
agpl · top 15,000 on PyPI
vultureVulture is a static code analyzer that finds…
permissive · top 5,000 on PyPI
django-upgradeAutomatically modernizes Django project code by…
permissive · top 15,000 on PyPI
pylamaPylama is a code audit tool that wraps multiple…
permissive · top 15,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
yesqayesqa automatically removes unnecessary `#…
permissive · top 15,000 on PyPI
darglintDarglint is a docstring linter that checks…
permissive · top 15,000 on PyPI
complexipyCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
fissixfissix is a backport of Python's lib2to3…
permissive · top 15,000 on PyPI
read-versionExtracts a version string or other variable…
permissive · top 15,000 on PyPI