Skip to main content

pyscythe

Codebase intelligence for Python. Dead code, circular imports, duplication, complexity, and architecture boundaries in one fast binary. The Python answer to fallow.

Built in Rust on the ruff and ty crates, so name resolution is semantic rather than textual: a symbol is only "used" when a reference actually binds to it.

Status

Early. pyscythe dead-code reports functions, classes, methods, properties, variables, and whole files that nothing refers to, resolving references semantically through ty (aliased imports, attribute access, re-exports). Dotted strings such as "pkg.settings.DEBUG" count as references. Methods that override an inherited member (walked through ty, so library bases count) are kept, and any attribute name accessed anywhere keeps same-named methods as a duck-typing safety net. pyscythe cycles reports import cycles that would bite at load time. pyscythe health measures cyclomatic and cognitive complexity per function, lists hotspots, and grades the codebase 0 to 100. pyscythe dupes finds copied code, including renamed copies, and reports the duplicated percentage. pyscythe boundaries enforces layering rules from pyproject.toml. pyscythe fix --dry-run shows the diff that would delete the dead code, and pyscythe fix applies it. pyscythe deps compares what pyproject.toml (PEP 621 or Poetry tables, or setup.py, setup.cfg, or pip requirements*.txt files) declares with what the code imports, per nested project in a monorepo, using the installed environment's metadata when there is one; an import that only arrives through a declared dependency (starlette via fastapi) is reported at low confidence. pytest's python_files, python_classes, and python_functions are honoured from pytest.ini, pyproject.toml, tox.ini, or setup.cfg. Built-in plugins keep symbols that frameworks reach by convention: pyproject entry points, pytest, FastAPI, Flask, Click/Typer, Celery, Airflow, Django, Alembic, SQLAlchemy/SQLModel, Pydantic. See TODO.md for the roadmap.

Install

The binary ships as a wheel on PyPI, so any Python tool runner works, and no Python is needed at runtime:

uvx pyscythe dead-code .            # run without installing
uv tool install pyscythe            # or: pipx install pyscythe
cargo install --locked --git https://github.com/jacobsieradzki/pyscythe pyscythe   # from source

Wheels are built for Linux (x86_64, aarch64), macOS (Intel, Apple silicon), and Windows (x86_64). crates.io is not an option while the ruff and ty crates are git dependencies.

Usage

pyscythe dead-code path/to/project
pyscythe dead-code path/to/project --format json
pyscythe dead-code path/to/project --no-plugins   # report every unreferenced symbol
pyscythe dead-code path/to/project --show-kept    # list what plugins suppressed, and why
pyscythe dead-code path/to/project --exclude scripts --exclude "**/legacy_*.py"
pyscythe cycles path/to/project

Confidence: high for private module-level names, medium for public ones and private methods, low for public methods, where overriding or reflection could hide a use.

Configuration lives in pyproject.toml:

[tool.pyscythe]
exclude = ["scripts", "**/legacy_*.py"]   # left out of reports; their references still count
ignore-names = ["deprecated_*"]           # symbols never reported
entry-points = ["pkg.worker:run"]         # extra roots beyond [project.scripts]
include-notebooks = false

public-modules = ["mylib"]         # a library: public names in these modules are API, not dead

[tool.pyscythe.deps]
ignore = ["some-pytest-plugin"]   # declared on purpose, never imported

[tool.pyscythe.health]
max-cyclomatic = 10
max-cognitive = 15
max-lines = 50
max-parameters = 6

[tool.pyscythe.boundaries]
layers = ["app.api", ["app.services", "app.workers"], "app.domain"]  # top to bottom
# or: preset = "hexagonal" with root = "app"

[[tool.pyscythe.boundaries.rules]]
from = "app.domain"
deny = ["app.infra"]

Exit codes: 0 clean, 1 findings, 2 error.

In CI

As a GitHub Action, which installs the PyPI wheel with uv (the action itself lives in this repository, so the runner needs access to it while the repository is private):

- uses: jacobsieradzki/pyscythe@main
  with:
    command: dead-code
    version: 0.1.0                      # omit for the latest release
    since: origin/${{ github.base_ref }}
    args: --min-confidence medium
pyscythe dead-code --format github          # GitHub Actions annotations
pyscythe dead-code --format sarif > out.sarif
pyscythe dead-code --format pr-comment      # a table with a marker a bot can find and update
pyscythe dead-code --min-confidence medium  # skip low-confidence method findings
pyscythe dead-code --since origin/main      # only files this branch changed

Adopting on an existing codebase: record what is there today, then fail only on new findings.

pyscythe dead-code --write-baseline .pyscythe-baseline.json
pyscythe dead-code --baseline .pyscythe-baseline.json

Silence a single finding where it happens:

def kept_for_a_reason() -> None:  # pyscythe: ignore
    ...

# pyscythe: ignore[unused-method]
def another() -> None:
    ...

# pyscythe: ignore-file anywhere in a file silences the whole file. A comment that silences nothing is itself reported, so suppressions do not rot.

Developing

Rust is managed by mise, which also installs cargo-shear and typos. Every warning is an error; clippy runs with pedantic and nursery on, rustdoc denies broken links, cargo shear fails on unused dependencies, and typos checks spelling. mise run check runs the whole gate, the same one CI runs.

mise install
mise run check

For Rust, the tools that map onto oxlint, oxfmt, and fallow are clippy, rustfmt, and rustc's own dead_code and unreachable_pub lints plus cargo shear; all are wired in here.

Releasing

Bump version in the workspace Cargo.toml, commit, then tag and push:

git tag v0.2.0 && git push origin v0.2.0

The release workflow builds the wheels and sdist with maturin, publishes them to PyPI through trusted publishing (the pypi environment, no token stored anywhere), and attaches the same files to a GitHub Release. uvx maturin build --release builds a wheel locally into target/wheels.

Layout

  • crates/pyscythe_core — domain model and analyses. No parser, no filesystem. Analyses are written against the CodebaseIndex port and tested with an in-memory fake.
  • crates/pyscythe_ty — the adapter that implements CodebaseIndex on the ty project database, including the parallel reference index.
  • crates/pyscythe_pyproject — reads pyproject.toml into the manifest and config.
  • crates/pyscythe_metrics — per-function complexity from the ruff AST alone, unit-tested on snippets.
  • crates/pyscythe_cli — the pyscythe binary, output formats, and acceptance tests that run the real binary over fixture projects.

Metadata

Release files for pyscythe 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyscythe 0.1.0
File Size Uploaded Provenance Actions
pyscythe-0.1.0.tar.gz 154.0 kB With provenance Details for pyscythe-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyscythe 0.1.0
File Actions
pyscythe-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pyscythe-0.1.0-py3-none-win_amd64.whl
pyscythe-0.1.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for pyscythe-0.1.0-py3-none-manylinux_2_28_x86_64.whl
pyscythe-0.1.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for pyscythe-0.1.0-py3-none-manylinux_2_28_aarch64.whl
pyscythe-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for pyscythe-0.1.0-py3-none-macosx_11_0_arm64.whl
pyscythe-0.1.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for pyscythe-0.1.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 55.6 MB

Release files / pyscythe-0.1.0.tar.gz

Download URL pyscythe-0.1.0.tar.gz
Size 154.0 kB
Tags Source
SHA-256 checksum
How to use checksums
756ffeaf8cbd19f581a691146025430e640654b4f5776766381cef7956e6e711
BLAKE2b-256 checksum
How to use checksums
8942d082d53c01b3a59ed332c9a926642a29bfb458c3d622d9fe58a909e912e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / pyscythe-0.1.0-py3-none-win_amd64.whl

Download URL pyscythe-0.1.0-py3-none-win_amd64.whl
Size 11.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
a2346a0259811fc1c045696ced346e69306557d5156e32eb401565055e6b30cf
BLAKE2b-256 checksum
How to use checksums
b9a8361be3c5eac829cbbd468a9de9bc14b57e6d4dfb33e685322a5b05e50ddf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / pyscythe-0.1.0-py3-none-manylinux_2_28_x86_64.whl

Download URL pyscythe-0.1.0-py3-none-manylinux_2_28_x86_64.whl
Size 11.5 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c751c43c5a217869abf82df44e2aa63e2b3632721f29f71a8b9cd29ddcaf52b5
BLAKE2b-256 checksum
How to use checksums
ad6f1900f076acb1339f4a266e345f175658107d78037ad1abccdc341a927c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / pyscythe-0.1.0-py3-none-manylinux_2_28_aarch64.whl

Download URL pyscythe-0.1.0-py3-none-manylinux_2_28_aarch64.whl
Size 10.8 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
bafadc97cdeda13a191288df602897f5fb34ea6020855af45e6d822a34ee077c
BLAKE2b-256 checksum
How to use checksums
fba2b519f82f578cb982ced0d5ee5489eea04c3bacb44b312f6c6cd00eb772b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / pyscythe-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL pyscythe-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 10.6 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7cb36cd6d43e5e2ed7cb0bf9254ea38d4e15401ad78d973d681bf318d79a850d
BLAKE2b-256 checksum
How to use checksums
62d9f4877578d85b05c4da5523b3f4b4355f061499d5095ba5f71db8e77f6553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / pyscythe-0.1.0-py3-none-macosx_10_12_x86_64.whl

Download URL pyscythe-0.1.0-py3-none-macosx_10_12_x86_64.whl
Size 11.2 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ac2cc7a64a79da63289cc6aa039b7803e4ca19f6495b566e6d437199544e275a
BLAKE2b-256 checksum
How to use checksums
b564527141fde1b1c8024f84e2f1ce25bd5caaf7f0edecf77f3c8af00ed0e937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Security for pyscythe 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pyscythe-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page