A script to analyze and clean Python files
Project description
pystreamliner
Automatically clean up messy Python files — without breaking anything.
pystreamliner uses Python's AST (abstract syntax tree) to safely detect and fix common code issues. It operates on two tiers: things it can fix automatically with zero risk, and things it flags for you to review manually.
What it does
Auto-fixes (Tier 1 — applied immediately):
- Removes unused imports, or trims partially unused
from x import ystatements - Removes consecutive duplicate lines
- Caps excessive blank lines
Warnings (Tier 2 — reported, never auto-changed):
- Unused variables
- Unused top-level functions
- Vague variable names (
x,tmp,foo,bar, etc.)
pystreamliner never touches code it isn't certain about. If there's any doubt, it warns you instead.
Install
git clone https://github.com/Supe232323/PyStreamliner.git
cd PyStreamliner
No dependencies. Runs on Python 3.10+.
Usage
python streamliner.py your_file.py
This will:
- Analyze
your_file.py - Write the cleaned version in-place
- Print a full report of what was changed and what needs manual review
- Show a diff of every modification
Preview changes without modifying anything:
python streamliner.py --dry-run your_file.py
Example output
══════════════════════════════════════════
PyStreamliner Report
══════════════════════════════════════════
File: main.py
Lines analyzed: 312
Auto-fixes applied:
Unused imports removed: 3
Duplicate lines removed: 1
Blank lines reduced: 2
Warnings (manual review needed):
Unused variables detected: 2
Unused functions detected: 1
Vague variable names: 1
──────────────────────────────────────────
Unused imports removed:
• line 4: import os
• line 5: import sys
• line 7: from pathlib import Path, PurePath (partially cleaned: kept 'Path')
Unused variables:
⚠ line 42: result
⚠ line 87: temp_val
Vague variable names:
⚠ line 23: tmp
══════════════════════════════════════════
Why not just use Black / isort / autoflake?
Those are great tools and pystreamliner doesn't replace them. The difference:
- Black formats style. pystreamliner removes dead code.
- autoflake removes unused imports but doesn't warn about unused variables, vague names, or dead functions.
- pystreamliner combines lightweight static analysis with conservative auto-fixing and a human-readable report — in a single file with zero dependencies.
Contributing
See CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
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 pystreamliner-1.12.1.tar.gz.
File metadata
- Download URL: pystreamliner-1.12.1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fdcdcaae95df4e0e3d725049e4b2a2c920b9816ffc85ded8206a0a3c0d4a504
|
|
| MD5 |
801080b2e2721e9bea9502edc6067b16
|
|
| BLAKE2b-256 |
53018ae53533b417cfb03dad14e28276c0909dac57a2f14fe50556a2264d0ae5
|
Provenance
The following attestation bundles were made for pystreamliner-1.12.1.tar.gz:
Publisher:
main.yml on Supe232323/pystreamliner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pystreamliner-1.12.1.tar.gz -
Subject digest:
6fdcdcaae95df4e0e3d725049e4b2a2c920b9816ffc85ded8206a0a3c0d4a504 - Sigstore transparency entry: 2188727729
- Sigstore integration time:
-
Permalink:
Supe232323/pystreamliner@029280a97e3868f9d6e78279a5b753050cbf9230 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Supe232323
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@029280a97e3868f9d6e78279a5b753050cbf9230 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pystreamliner-1.12.1-py3-none-any.whl.
File metadata
- Download URL: pystreamliner-1.12.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ae9e34577da2012ae68b300c2e62a41c3eee963e1db6564f4a1ff7d0676d062
|
|
| MD5 |
bc78686697f6f256f6779658aa207d2a
|
|
| BLAKE2b-256 |
4ee6de20ba3584378583f54f161962d81a521d5b0c2f9d0640e7419ca2dbcdcf
|
Provenance
The following attestation bundles were made for pystreamliner-1.12.1-py3-none-any.whl:
Publisher:
main.yml on Supe232323/pystreamliner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pystreamliner-1.12.1-py3-none-any.whl -
Subject digest:
9ae9e34577da2012ae68b300c2e62a41c3eee963e1db6564f4a1ff7d0676d062 - Sigstore transparency entry: 2188727752
- Sigstore integration time:
-
Permalink:
Supe232323/pystreamliner@029280a97e3868f9d6e78279a5b753050cbf9230 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Supe232323
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@029280a97e3868f9d6e78279a5b753050cbf9230 -
Trigger Event:
push
-
Statement type: