Skip to main content

sharpit

CI Release PyPI version Python 3.12 | 3.13 | 3.14 Licence: Apache-2.0 Status: alpha Code style: ruff Type checked: pyright

See inside your running FastAPI app. One call mounts a developer console at /sharpit: your configuration and where each value came from, every route, every SQL statement with the request that ran it, exceptions, HTTP exchanges and health. It is a Python port of BootUI by Julien Dubois (Apache-2.0), the Spring Boot developer console: the same design goals, JSON contract and test cases, with a new UI.

pip install "sharpit[fastapi]"      # or: uv add "sharpit[fastapi]"
from fastapi import FastAPI
import sharpit

app = FastAPI()

# Register your application middleware first, then mount sharpit:
sharpit.install(app)  # mounts /sharpit and /sharpit/api
fastapi dev app.py          # or: uvicorn app:app --reload; then open http://127.0.0.1:8000/sharpit/

sharpit overview

What you get: 46 panels. Change a logger's level while the app runs, spot N+1 queries per route, and scan your installed packages for known vulnerabilities when you ask for it. Every panel in light and dark: screenshot catalog.

Safe to leave in your dev setup:

  • Off unless a dev signal turns it on (fastapi dev, uvicorn --reload, or a dev profile). Otherwise every path under /sharpit answers 404.
  • Loopback callers only. A forwarding header never grants trust, and remote access needs a token.
  • Secret-looking names and values are masked by default. Showing them takes an explicit switch (SHARPIT_EXPOSE_VALUES=FULL, or SQL parameter capture), and sharpit warns at startup when one is on.
  • Reading a panel makes no network call, writes no file and changes no logger level.

Then gate CI on it: pytest --sharpit fails a test that goes over its query budget, triggers an N+1 query or swallows an exception, and runs the REST API advisor over your routes. When capture cannot see enough to judge, the run fails closed.

Status: alpha (0.6.0, FastAPI only). Django and Flask are not supported. See CHANGELOG.md.

Gate CI on findings

pytest --sharpit turns runtime capture into test gates. It tracks SQL statements and observable exceptions per test, detects N+1 queries, checks query budgets, and runs the REST API advisor over your app's routes. If a test exceeds its query budget, triggers an N+1 query, or swallows an unhandled exception, the build fails. When capture cannot see enough to judge, the run status is unknown and fails closed.

pytest --sharpit --sharpit-report=sharpit-report.json --sharpit-junit=sharpit-junit.xml

sharpit finds your app on its own: the one FastAPI or Starlette app defined in the modules your tests already imported. It never imports a module to look. Pass --sharpit-app module:attr when there are several. With none, several, or one without routes, the REST API advisor is SKIPPED and a clean suite still passes; --sharpit-require-app makes that unknown. The terminal gate counts: lists only findings that fail the gate; --sharpit-verbose (or -vv) lists every one. The JSON report and JUnit file always hold every finding.

Adopting on an existing suite

Start without breaking the build, then freeze what is already there:

pytest --sharpit --sharpit-report-only                      # report everything, fail on nothing but blindness
pytest --sharpit --sharpit-write-baseline=sharpit-baseline.json   # after a complete run: record today's findings
pytest --sharpit --sharpit-baseline=sharpit-baseline.json         # in CI: only new findings fail
  • Report-only (--sharpit-report-only, ini sharpit_report_only = true) runs every gate and advisor and writes the report, but findings do not fail tests or the session. An unknown reason still exits 1 unless --sharpit-allow-unknown: report-only relaxes findings, never blindness.
  • Baselines match findings by fingerprint. A listed finding is existing and never fails, an unlisted one is new and gates as usual, a listed one not seen is fixed. A count gate that grows past its baselined count is new. Vulnerability findings are not baselined, and INFO findings never fail.
  • --sharpit-write-baseline=PATH is the only way a baseline is written. It refuses a partial run (-k, -m, node ids, --lf, --deselect, -x stopping early, an interrupt) and a run with any unknown reason.
  • A missing or malformed baseline never switches sharpit off: the session runs and the baseline becomes an unknown reason, which fails the run. Own the baseline file in CODEOWNERS, or a PR can baseline its own findings.

See The safety gate for exit-status behavior and the baseline workflow.

GitHub Action

The repository root is a composite action (action.yml) that runs pytest with sharpit and writes a findings summary to the job summary. Pin it to a release tag:

- uses: ffroliva/sharpit@<release tag>
  with:
    pytest-args: "-q tests/"
    baseline: sharpit-baseline.json

Inputs: pytest-args (split with Python shlex), report-only (default "true": findings are reported, never fail the build), baseline, fail-on (lowest severity that fails), report-path (default sharpit-report.json), install (pip installs the pinned sharpit; none when your project already depends on it, in which case python must be able to import sharpit) and runner (default python -m pytest, for example uv run pytest). Set report-only: "false" to gate. The pytest exit code is never masked: the summary step runs if: always() and only warns if it fails. The summary is rendered by python -m sharpit.report summary <report.json>. On Windows runners runner and pytest-args are split in non-POSIX mode so backslashes in paths survive.

On the author's own project: gflow-cli

Run by sharpit's author on the 0.3.0 integration branch against gflow-cli (a public FastAPI daemon using raw sqlite3; see sharpit's own report), sharpit ran across 5,662 tests (5 failed by sharpit gates):

  • 0 unattributed SQL statements across ~53k statements executed (27,997 attributed + 25,092 filtered);
  • 6 N+1 findings, of which 1 was a real defect, 2 were noise (filtered since 0.3.0), and 3 were expected polling;
  • No production code was changed to get these numbers.

Installation and extras

Python 3.12+. Runtime dependencies are only starlette>=0.44 and packaging>=23.

pip install "sharpit[fastapi]"

Optional extras:

Extra Adds Why
sharpit[fastapi] fastapi>=0.115 the supported host
sharpit[settings] pydantic-settings>=2.4 the Config panel shows which source each value came from

Configuration and activation

Call sharpit.install(app) after adding your own middleware. Starlette builds middleware from the outside in, so calling install() last ensures sharpit's capture middleware sits outside your application middleware. This lets sharpit measure total request durations and record unhandled errors correctly.

Keyword arguments for sharpit.install():

  • engines: optional sequence of SQLAlchemy Engine or AsyncEngine instances to monitor in connection pools and health checks (e.g. engines=[engine]). If omitted, engines are discovered automatically on first connection.
  • health_checks: optional mapping of check names to zero-argument callables (e.g. health_checks={"cache": ping_cache}).
  • alembic_config: optional path to alembic.ini (default "alembic.ini").
  • settings: optional pydantic-settings instance or sequence of instances to show configuration provenance.
  • models: optional SQLAlchemy 2.0 declarative base, registry, or a list of them or of mapped classes, for the Data panel (e.g. models=Base). sharpit never configures mappers or runs SQL to read them.

With a PostgreSQL engine, the PostgreSQL panel reads vital signs, sessions, statements, indexes, tables, vacuum, replication and settings on an explicit POST /sharpit/api/postgresql/read: one read-only transaction with statement and lock timeouts, a read budget and row limits, query text masked. GET returns the last read and never touches the database.

The sqlalchemy-statistics panel (BootUI's hibernate-statistics; GET {api}/sqlalchemy-statistics, MCP get_sqlalchemy_statistics) shows statement counts from SQL Trace's lifetime totals, the slowest statement and N+1 candidates per route. SQLAlchemy reports SQL statements, not ORM sessions or entities, so the Hibernate-only counters (sessions, flushes, transactions, entity and collection counts) are null, each with a reason. It needs SQL Trace, and reports statistics.warnings when SQL Trace recording is paused.

Other options are keyword arguments or environment variables, see Settings.

If /sharpit answers 404, read Activation: sharpit stays off unless a dev signal turns it on.

Documentation

The full documentation is at https://ffroliva.github.io/sharpit/:

Licence

Apache License 2.0. See LICENSE and NOTICE. sharpit is derived from BootUI, Copyright Julien Dubois.

Code quality

Quality Gate Coverage

Reliability Security Maintainability Duplication

Metadata

Release files for sharpit 0.6.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 sharpit 0.6.0
File Size Uploaded Provenance Actions
sharpit-0.6.0.tar.gz 2.9 MB With provenance Details for sharpit-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sharpit 0.6.0
File Interpreter ABI Platform Actions
sharpit-0.6.0-py3-none-any.whl Python 3 none any Details for sharpit-0.6.0-py3-none-any.whl

Total release size: 3.7 MB

Release files / sharpit-0.6.0.tar.gz

Download URL sharpit-0.6.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
a0ad5061982e600458c0046944734c45256c8dbd67e5b9b311d7f667a791c8e9
BLAKE2b-256 checksum
How to use checksums
8c2f18ad8cfe2d5ecd45783edbf887fb1a97d1a9b699ffbb1c080ecafbc3b11c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / sharpit-0.6.0-py3-none-any.whl

Download URL sharpit-0.6.0-py3-none-any.whl
Size 849.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c220b72345a5b77782945abe5e4b73d296117a4e3da7ee323944c01041534112
BLAKE2b-256 checksum
How to use checksums
4b2822c2df07201db22e49c3bf7e3669b4af33d9e9bc346d7212604f95ed804c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for sharpit 0.6.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sharpit-0.6.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 Nov 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