Pycleancode: Professional Python Clean Code Toolkit
A Python toolkit to help developers write professional-grade, maintainable, and clean code following clean code principles.
pycleancode is a professional-grade Python toolkit that helps developers write clean, maintainable, and scalable code following clean code principles.
๐ Project Goal
Build multiple code quality tools under a single unified package architecture.
Unlike traditional linters that only focus on style violations, pycleancode implements advanced rule engines that target deeper structural and maintainability aspects of your code.
๐ Why pycleancode?
While tools like flake8, pylint, ruff, and black are excellent, most focus heavily on surface-level syntax or style violations.
pycleancode is different:
- ๐ Designed for professional teams writing critical Python codebases.
- ๐ค Rule-based pluggable architecture to extend new structural checks.
- ๐ AST-powered deep nesting detection.
- ๐ก Focused on long-term maintainability.
- ๐ฆ OSS-grade code architecture.
๐ Current Release - v1.1.0
pycleancode 1.1.0 โ "Output teams can use" โ adds a unified pycleancode check CLI, JSON and Markdown reports, severity-aware exit codes for CI, and pyproject.toml configuration on top of the brace_linter module.
New in 1.1.0
- Unified CLI โ
pycleancode check <path>replacespycleancode-brace-linter(the old command still works and prints a deprecation notice; removal planned for 2.0). - Report formats โ
--format text|json|markdownwith optional--output <file>. JSON carries a stableschemaVersion: 1for CI integrations; Markdown is ready to paste into a pull request. - Exit codes for CI โ
0clean or warnings-only,1error violations,2usage/config/parse failure. Builds can finally fail on maintainability regressions. - Per-rule severity โ set
severity: warningon a rule to report without failing the build, then tighten toerrorwhen the team is ready. - Layered configuration โ
--config <path>โ./pybrace.ymlโ[tool.pycleancode]inpyproject.tomlโ built-in defaults. Fresh installs run with zero setup.
Brace Linter
The brace_linter module focuses on structural code depth and complexity. It analyzes Python code for excessive nesting and deeply nested functions that often make code harder to read, maintain, and extend.
Key Features
-
Max Depth Rule
- Enforces maximum logical nesting depth.
- Helps prevent pyramid-of-doom structures.
-
Nested Function Rule
- Enforces maximum levels of nested function definitions.
- Prevents excessive local function scoping that can reduce readability.
-
Structural Reporting
- Full structural report of nesting tree.
- Emoji + ASCII visualization of code structure.
- Summary chart output for quick depth evaluation.
Sample output:
sandbox/test_sample.py:2: Nested functions depth 2 exceeds allowed 1
sandbox/test_sample.py:3: Depth 4 exceeds max 3
๐ Structural Report:
๐พ ROOT (Line 0, Depth 1)
โ ๐น FunctionDef (Line 1, Depth 2)
โ โ ๐น FunctionDef (Line 2, Depth 3)
โ โ โ ๐น FunctionDef (Line 3, Depth 4)
๐ก Python Compatibility
- โ Supported Python versions: 3.9, 3.10, 3.11, 3.12
- โ Python 3.13+ is not yet supported (due to upstream Rust dependencies)
๐ Installation
Install via PyPI:
pip install pycleancode
Or using Poetry:
poetry add pycleancode
๐ง Basic Usage
Run directly via CLI:
pycleancode check path/to/your/code.py --report
Generate machine-readable or review-friendly reports:
pycleancode check src --format json --output report.json
pycleancode check src --format markdown --output report.md
Exit codes: 0 = clean or warnings-only ยท 1 = error-severity violations ยท 2 = usage/config/parse failure.
The legacy
pycleancode-brace-lintercommand still works with its original arguments and prints a deprecation notice. Migrate scripts topycleancode check.
๐ Configuration
Configuration is discovered in this order: --config <path> โ ./pybrace.yml โ [tool.pycleancode] in pyproject.toml โ built-in defaults.
Via pybrace.yml:
rules:
max_depth:
enabled: true
max_depth: 3
nested_function:
enabled: true
max_nested: 1
severity: warning # report, but do not fail the build
Or via pyproject.toml:
[tool.pycleancode.rules.max_depth]
enabled = true
max_depth = 3
[tool.pycleancode.rules.nested_function]
enabled = true
max_nested = 1
severity = "warning"
Each rule accepts enabled, its thresholds, and an optional severity (error by default, warning to report without failing CI).
๐ง Development Setup
git clone git@github.com:YOUR_USERNAME/pycleancode.git
cd pycleancode
poetry install
pre-commit install
Run full tests:
poetry run pytest --cov=pycleancode --cov-report=term-missing
Run pre-commit:
poetry run pre-commit run --all-files
๐ Roadmap
| Module / Feature | Description | Status |
|---|---|---|
brace_linter |
Structural depth analysis (nesting, functions) | โ Completed |
| Team-usable output | JSON/Markdown reports, exit codes, pyproject config | โ v1.1.0 |
| Regression diff mode | diff --base main: fail CI only on regressions |
โณ Planned (v1.2) |
| Baseline & ratchet | Adopt on legacy codebases without fixing old debt | โณ Planned (v1.3) |
| GitHub Action | PR comments, status checks, annotations | โณ Planned (v1.4) |
| Full documentation site | OSS-grade docs & API reference | โ Live |
๐ License
Released under the MIT License. See LICENSE.
๐ก๏ธ Code of Conduct
Please see our CODE_OF_CONDUCT.md
๐ Contributing
We welcome OSS contributions. Please read our full CONTRIBUTING.md to get started!
- Clean Code Principles
- 100% Test Coverage Required
- Pre-commit Hooks Required
- Conventional Commits Required
๐ Community
- GitHub Discussions (coming soon)
- Issues and PRs welcomed
- PyPI release v1.1.0 adds team-usable output: reports, exit codes, and pyproject configuration
๐ Pycleancode: Clean Code. Professional Quality. OSS-Grade Python. Unified Modular Clean Code Toolkit.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycleancode-1.1.0.tar.gz.
File metadata
- Download URL: pycleancode-1.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9e0ab3e4f138241cac97a6199bc0997a5e174c46b5b2570fbd54a8f92e0721c
|
|
| MD5 |
d594ba3ea5632293ab5e606bb4aa8dde
|
|
| BLAKE2b-256 |
d4b3b2e086f55b0e696de91a0244777b3de6e8f58e174cc5738480c05e5b112d
|
Provenance
The following attestation bundles were made for pycleancode-1.1.0.tar.gz:
Publisher:
workflow.yml on pycleancode/pycleancode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycleancode-1.1.0.tar.gz -
Subject digest:
a9e0ab3e4f138241cac97a6199bc0997a5e174c46b5b2570fbd54a8f92e0721c - Sigstore transparency entry: 2185794767
- Sigstore integration time:
-
Permalink:
pycleancode/pycleancode@cbe13fc6519af433e667bb7d04cb359fe47f2e78 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/pycleancode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@cbe13fc6519af433e667bb7d04cb359fe47f2e78 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycleancode-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pycleancode-1.1.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84d725a4ef7a6ecc2c3e390285a74c9b2f5d4883d2f0d4004a4217b498a0aa82
|
|
| MD5 |
e9176212f41d4a8d4a07df18071190b0
|
|
| BLAKE2b-256 |
072796a92c8d18c67f21fad3c686a774e32d026fa2b2a726319d949b79f8405f
|
Provenance
The following attestation bundles were made for pycleancode-1.1.0-py3-none-any.whl:
Publisher:
workflow.yml on pycleancode/pycleancode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycleancode-1.1.0-py3-none-any.whl -
Subject digest:
84d725a4ef7a6ecc2c3e390285a74c9b2f5d4883d2f0d4004a4217b498a0aa82 - Sigstore transparency entry: 2185794918
- Sigstore integration time:
-
Permalink:
pycleancode/pycleancode@cbe13fc6519af433e667bb7d04cb359fe47f2e78 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/pycleancode
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@cbe13fc6519af433e667bb7d04cb359fe47f2e78 -
Trigger Event:
push
-
Statement type: