dosisod/refurb: a mypy-powered linter for modernizing Python code
A tool for refurbishing and modernizing Python codebases
At a glance
- What is it?
- Refurb is a command line linter that reports modernization suggestions rather than editing files. It runs on top of mypy and emits FURB-prefixed findings for Python codebases that are already type-checked.
- Who is it for?
- Adopt Refurb if your codebase is already type-checked and you want an opinionated push toward modern idioms, especially on new code where enable_all is a reasonable starting point. Skip it if you need a tool that rewrites files, if you cannot run a linter on Python 3.10 or newer, or if GPL-3.0-only is incompatible with how you ship.
- Can I use it commercially?
- Yes, with conditions. GPL-3.0 is a copyleft licence: if you distribute software that includes it, you must release that software's source code under the same licence. Running it internally without distributing it does not trigger that obligation.
- Is it still maintained?
- Yes. The repository last received commits 25 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- dosisod/refurb2,532 ★ · -1
| Repository | 2026-09-30 | 2026-11-22 |
|---|---|---|
| dosisod/refurb | 2.5k | 2.5k |
-1 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What Refurb actually checks, and who it is for
Refurb is a Python linter with a narrow thesis: a lot of code is written in an older idiom than the language now supports, and a type-aware tool can point that out precisely. The README calls it "a tool for refurbishing and modernizing Python codebases", and the checks it ships are the concrete form of that claim. The example in the README shows four findings on a single file: a list literal used where a tuple would do, a manual open/read pattern that could be Path.read_text(), two startswith calls that could become one call with a tuple, and print("") that could be print(). Each finding carries a code such as FURB101 or FURB109 and a suggested replacement.
The audience follows from the mechanism. Refurb depends on mypy, so it is not a standalone parser. The pyproject.toml lists mypy as a runtime dependency with the constraint ">=1.10.0,!=1.11.0", which means Refurb inherits mypy's type information and inherits mypy's cost. If your project already runs mypy in CI, adding Refurb is mostly a matter of adding one more command. If your project has never been type-checked, you are adopting a type checker as a side effect of adopting a linter, and that is a much larger decision than the README's install section suggests.
It is not a formatter. Refurb reports; it does not edit. The Makefile in the repository shows the maintainer's own workflow, and the test target runs refurb against the project's own source, which is the strongest signal in the repository that the tool is meant to be run on real code rather than demo files.
How Refurb uses mypy to find modernization opportunities
The architecture is a thin layer over mypy. Refurb loads your files, hands them to mypy for analysis, and then walks the resulting typed syntax tree with its own visitor checks. Each check is registered under a FURB code, and the tool reports the line, column, code and message in the format file.py:1:5 [FURB123]: Replace int(x) with x.
That design explains several behaviours that would otherwise look arbitrary. Checks that need type information can exist at all because mypy has already resolved the types. Checks that are risky or noisy can ship disabled by default, because the maintainers can require an explicit --enable. And the tool can be extended by plugins, since --load takes a module name; the README's config example uses load = ["some_module"].
The dependency also means Refurb's behaviour is coupled to the mypy version you install. The exclusion of mypy 1.11.0 in pyproject.toml is a version pin, not a stylistic choice, and it tells you the maintainers track mypy releases closely enough to react to a broken one. Arguments after -- are forwarded to mypy, and the README gives refurb files -- --show-traceback as the example, which is useful when mypy crashes rather than when Refurb does.
One consequence is worth stating plainly: Refurb's error list is not a style guide. It is a set of mechanical rewrites that the maintainers judged safe enough to automate. Reading --explain for a code before enabling it is the intended workflow, not an optional courtesy.
Installing Refurb and running it on a real directory
The README gives pipx as the install path, which keeps Refurb in its own environment and avoids polluting your project's dependencies. The same command also runs it against a file or a folder.
pipx install refurb
refurb file.py folder/The README notes that Refurb must run on Python 3.10 or newer, though it can check Python 3.7 and later code by setting the --python-version flag. That distinction matters on machines where the interpreter running Refurb is not the interpreter your code targets.
To see what a specific finding means, look it up by code. The README shows this exact invocation.
refurb --explain FURB123The explanation includes a bad example and a good example, which is usually enough to decide whether the rewrite applies to your code. An online list of all checks lives in docs/checks.md in the repository.
For a first real run, the Makefile's own test-generation rule uses this combination of flags.
refurb test/e2e/dummy.pyExpect a long list on an older codebase. That is the point of --disable-all, which lets you start from zero and enable checks one at a time instead of suppressing a wall of output. In the config file the equivalent keys are disable_all and enable_all, and the README states they are mutually exclusive both on the command line and in the config file.
Settings live in pyproject.toml under [tool.refurb]. The README maps a command line invocation directly onto the file form.
[tool.refurb]
ignore = [100]
load = ["some_module"]
quiet = trueValues from the config file merge with command line values. For boolean arguments such as --quiet the command line wins; for list arguments such as ignore and load the two are combined. A --config-file flag points at a different file, which must still have the normal pyproject.toml shape.
Where Refurb gets in the way
The most concrete limitation is the Python version floor. Refurb itself needs Python 3.10 or newer. The --python-version flag only changes which language features Refurb expects in the code it inspects; it does not lower the interpreter requirement for running the tool. A team pinned to 3.8 or 3.9 for deployment cannot run Refurb in that environment, and would need a separate interpreter or CI image just for linting.
The second limitation is the mypy dependency. Refurb is not a fast syntax-only checker. It pays the cost of type analysis on every run, and it inherits mypy's failure modes. The README's -- passthrough exists precisely because mypy can crash and you may want a traceback. A codebase with heavy untyped dependencies will produce weaker results, since the checks that depend on resolved types have less to work with.
The third is scope. Refurb reports; it does not fix. If your goal is automatic rewriting of a large legacy tree, Refurb will hand you a list and leave the edits to you. The README's example output is a list of suggestions, and nothing in the repository layout suggests an autofix mode.
Finally, the check set is opinionated and partly off by default. The distinction the README draws is precise: a disabled check is never loaded, while an ignored check is loaded, emits an error, and has that error suppressed. Teams that want a small, stable rule set should use --disable-all plus explicit enables rather than --ignore, because an ignored check still costs the work of running it.
Refurb compared with Ruff, and when the difference matters
The obvious alternative in the same ecosystem is Ruff. The repository's own pyproject.toml configures Ruff with lint.select = ["ALL"], and the Makefile runs both ruff check and refurb as separate targets. That is the clearest statement of the relationship: the maintainers treat them as complementary, not competing.
The difference in approach is the analysis engine. Ruff is a fast linter with its own parser, and its rule set covers style, imports, and a large body of pyflakes- and pycodestyle-derived checks. Refurb delegates to mypy, so its checks can reason about inferred types in a way a syntax-only linter cannot, and it inherits mypy's slower, more thorough pass. The README's example check FURB123, "Don't cast a variable or literal if it is already of that type", is exactly the kind of finding that needs type information.
So the practical split is: Ruff for breadth and speed, Refurb for type-aware modernization suggestions. If you already run mypy, Refurb adds a check layer on top of an analysis you are already paying for. If you do not run mypy, Refurb is the more expensive of the two to adopt, and Ruff alone will cover most of the mechanical style ground. Choosing Refurb over Ruff is choosing a narrower rule set in exchange for type awareness, not choosing a better linter.
Maintenance, licensing, and what upgrading looks like
The repository is not archived, and the last push was on 2026-04-03, which is the same date as the v2.3.1 release. The release history shows v2.3.0 on 2026-02-21 and v2.2.0 on 2025-09-17, so the cadence over the past year has been a few releases rather than continuous churn.
The upgrade cost is dominated by the mypy pin, not by Refurb's own version number. pyproject.toml declares mypy with the constraint ">=1.10.0,!=1.11.0", so a mypy upgrade can change what Refurb reports even when the Refurb version is unchanged. The Makefile's test-generation rule shows how the maintainers handle this: test/%.txt files are regenerated by running refurb against test/%.py with --enable-all --quiet --no-color, and update-tests regenerates them all. If you pin Refurb in CI, pin mypy alongside it, and expect the output of --enable-all to shift when either moves.
On licensing, pyproject.toml declares "GPL-3.0-only" and the classifiers list "License :: OSI Approved :: GNU General Public License v3 (GPLv3)". Refurb is a command line tool you invoke, not a library you link into your application, but GPL-3.0-only is a copyleft licence and the question of what counts as distribution is fact-specific. Teams with strict licence review should route this through their own process rather than assume the CLI boundary settles it. Nothing here is legal advice.
The project is typed and strict about it: the mypy configuration in pyproject.toml sets strict = true along with disallow_any_explicit and warn_unreachable, and the pytest configuration sets --cov-fail-under=100. That is a meaningful signal about the maintainers' standards for the code they accept, and it also means contributing a new check comes with a test and coverage obligation.
Editorial conclusion
Adopt Refurb if your codebase is already type-checked and you want an opinionated push toward modern idioms, especially on new code where enable_all is a reasonable starting point. Skip it if you need a tool that rewrites files, if you cannot run a linter on Python 3.10 or newer, or if GPL-3.0-only is incompatible with how you ship. Before committing, run refurb on a small directory and read the --explain output for each FURB code it reports.
Frequently asked questions
How do I install Refurb?
The README gives pipx install refurb, after which you run it as refurb file.py folder/. Refurb must run on Python 3.10 or newer.
Does Refurb rewrite my Python files automatically?
No. Refurb reports findings with a file, line, column, FURB code and a suggested replacement, and leaves the edit to you. The README's example output is a list of suggestions rather than a diff.
What is the difference between --ignore and --disable in Refurb?
An ignored check is still loaded and still emits an error, but the error is suppressed; a disabled check is never loaded at all. The README notes that --disable-all plus explicit --enable calls is the way to build up a rule set incrementally.
How do I look up what a FURB code means?
Run refurb --explain FURB123, substituting the code you saw. The output shows a bad example and a good example, and docs/checks.md in the repository lists all available checks.
Can I configure Refurb in pyproject.toml?
Yes. Settings go under [tool.refurb], with keys such as ignore, load and quiet. Config file values merge with command line values, and for boolean arguments the command line takes precedence.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/dosisod-refurb)Star history chart for your README
[](https://hysenlabs.com/projects/dosisod-refurb)Was this useful?