# asottile/pyupgrade

A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.

Repository: https://github.com/asottile/pyupgrade
Canonical: https://ross.abutalabs.com/products/pyupgrade
Language: Python
License: MIT
License Family: permissive
Topics: python, pre-commit, linter
Last push: 2026-08-25T19:30:18+00:00

## Health v2 (maintenance only)
Score: 77/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 35, longevity 100
- inputs: {"age_days": 3473, "days_push": 8, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 4113, forks 217 (observed 2026-08-28T04:08:35.780301+00:00)

## What it is
pyupgrade is a CLI tool and pre-commit hook that automatically rewrites Python source code to use modern syntax for newer Python versions. It applies safe, opinionated fixes such as set literals, dict comprehensions, f-string-friendly formatting, and removal of obsolete unicode literals.

## Use cases
- automatically upgrade python syntax to newer versions
- modernize legacy python codebase
- add a pre-commit hook to fix outdated python syntax
- convert printf-style formatting to str.format
- remove unnecessary lambdas in defaultdict calls
- fix invalid escape sequences in strings

## When to choose
- you want automated, safe syntax upgrades for python code
- you already use pre-commit and want an autofix hook
- you are migrating a codebase toward newer python versions

## When to avoid
- you need general-purpose linting beyond syntax upgrades (use ruff or flake8)
- you want to preserve legacy formatting exactly as-is
- you work in a non-python language

## Facets
- artifact type: cli-tool
- maturity: active
- function: linter, formatter, cli
- domain: developer-tools, programming-languages
- platform: python, cli, cross-platform
- tags: python, pre-commit, code-modernization, syntax-upgrade, autofix, automation

## Member repositories
- asottile/pyupgrade (main) score 77

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:35.780301+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:23:10.923717+00:00, confidence not recorded.
  - readme: https://github.com/asottile/pyupgrade (fetched 2026-08-28T04:08:35.780301+00:00, sha f9dec645cf9e)
  - registry_pypi: https://pypi.org/pypi/pyupgrade/json (fetched 2026-08-29T09:14:38.772648+00:00, sha 9bc2619da34d)
- Data as of 2026-08-30T08:39:29.467469+00:00.
