ballpython
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_CHECKINGguards, and prunes unused imports. - Formatting & Modernization: Formats code to PEP 8 standards (powered by
ruff), modernizes legacy type annotations (PEP 585/604), and removes redundantobjectinheritance. - 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/picklecalls. - 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.3
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.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ballpython-2.0.3.tar.gz | 117.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ballpython-2.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 228.1 kB
Release files / ballpython-2.0.3.tar.gz
| Download URL | ballpython-2.0.3.tar.gz |
|---|---|
| Size | 117.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
254be5bf06d7039982f3ab942f094895fa96b5341d8007b615c01bd416225e08
|
|
BLAKE2b-256 checksum How to use checksums |
d9fcd80c4db30d985411de710c79c7309e08f2bd250776f68ec1af0617306360
|
| 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 20, 2026.
Transparency logRelease files / ballpython-2.0.3-py3-none-any.whl
| Download URL | ballpython-2.0.3-py3-none-any.whl |
|---|---|
| Size | 110.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10d3debe3f6ba2dda433b4849e70b21f20e3a0c7d5a0995b572551cfbc25c239
|
|
BLAKE2b-256 checksum How to use checksums |
131f5781d4190d011358491d61a20b6e38e060ee6f33237c9cc5bbde3c7c3e3f
|
| 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 20, 2026.
Transparency log