Skip to main content

ballpython

PyPI version Python Versions CI License: MIT

The zero-config Python code cleaner, syntax healer, and quality suite.

ballpython automatically repairs broken syntax, resolves missing imports, prunes dead code, scans for security vulnerabilities, and formats your code in a single command. Zero LLM dependencies, 100% offline, and fast.

Both ballpython and pycleaner CLI commands are identical.


Installation

pip install ballpython

Quickstart

1. Fix and format your code

Run ballpython on any file or directory. It automatically heals syntax errors, resolves missing imports, removes unused variables, and applies canonical formatting:

ballpython .

2. Check code in CI (Dry Run)

Check for syntax errors, security vulnerabilities, dead code, and linting violations without modifying any files on disk:

ballpython check .

What It Does Automatically

When you run ballpython, all engines run under the hood in one pass:

  • Syntax Healing: Repairs missing statement colons (def, class, if), accidental = assignments in conditionals, unclosed parentheses/brackets, tab/space mixups, and legacy Python 2 except/print statements.
  • Smart Import Resolution: Resolves undefined symbols to standard library modules and common aliases, inserts TYPE_CHECKING guards, and prunes unused imports.
  • Formatting & Modernization: Formats code to PEP 8 standards (powered by ruff), modernizes legacy type annotations (PEP 585/604), and removes redundant object inheritance.
  • Dead Code Pruning: Discovers and eliminates unreachable code, empty pass blocks, and unused private definitions.
  • Security & Taint Audit: Detects hardcoded API secrets, SQL/command injection patterns, and unsafe eval/exec/pickle calls.
  • Type Verification: Verifies function call signatures against bundled Typeshed stubs.

Pre-Commit Hook

Add ballpython to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/moonrox420/ball-python
    rev: v2.0.5
    hooks:
      - id: pycleaner
        args: ["check"]

Configuration

Optional configuration can be placed in pyproject.toml under [tool.pycleaner]:

[tool.pycleaner]
exclude = ["migrations/", "generated/"]
line-length = 88

License

MIT License.

Metadata

Release files for ballpython 2.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 ballpython 2.1.0
File Size Uploaded
ballpython-2.1.0.tar.gz 126.5 kB Details

Built distribution (wheel)

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

Total release size: 244.0 kB

Release files / ballpython-2.1.0.tar.gz

Download URL ballpython-2.1.0.tar.gz
Size 126.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e546bc3bc79715b3542d416a5688feea45c749e4008a952d0d93cd52b27db03e
BLAKE2b-256 checksum
How to use checksums
393379cc62516b1486c242ef490060f773250026ac23b12f07b414a101544601
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 21, 2026.

Transparency log

Release files / ballpython-2.1.0-py3-none-any.whl

Download URL ballpython-2.1.0-py3-none-any.whl
Size 117.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7ee0eefaa6e023c5e051d5f55c0ca97c2479f61b62862fb5c6688a06a6b64a2
BLAKE2b-256 checksum
How to use checksums
d2244470010e95a5e923f10887b62f1fdfb7ebb0ffa1aaefa7638168a4fbca52
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 21, 2026.

Transparency log

Release history Release notifications | RSS feed

2.1.2

2 release files

2.1.1

2 release files

This release

2.1.0 This release

2 release files

2.0.7

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.0

2 release files

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