Skip to main content

pystreamliner

PyPI version PyPI downloads

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.

Supports single files, multiple files, and recursive directory cleaning with a tight summary mode for large runs.


What it does

Auto-fixes (Tier 1 — applied immediately):

  • Removes unused imports, or trims partially unused from x import y statements
  • 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.)
  • Shadowed built-ins
  • Dangerous calls (eval, exec, pickle, os.system, subprocess(..., shell=True), unsafe yaml.load)
  • Possible hardcoded secrets
  • Assert statements
  • Broad except: / except Exception

pystreamliner never touches code it isn't certain about. If there's any doubt, it warns you instead.


Install

pip install pystreamliner

No dependencies. Runs on Python 3.13+.


Usage

Single file:

pystreamliner your_file.py

Multiple files:

pystreamliner file1.py file2.py utils/*.py

Entire project (recursive):

pystreamliner .
# or
pystreamliner src/ tests/

Directories are walked recursively. Common junk directories (.git, __pycache__, venv, node_modules, etc.) are automatically skipped.

Preview without modifying:

pystreamliner --dry-run .

CI mode (exit non-zero on issues):

pystreamliner --check --quiet .

Big runs / Summary mode

When you process 5 or more files (configurable with --summary-threshold), pystreamliner switches to a compact summary instead of dumping a full report for every file:

══════════════════════════════════════════════════
 pystreamliner summary
══════════════════════════════════════════════════
 Files processed:         47
 Clean (no issues):       39
 Modified:                 6
 Warnings only:            2

 Totals:
 Unused imports removed:      14
 Duplicate lines removed:      3
 Blank lines reduced:         11
 Warnings issued:              8
──────────────────────────────────────────────────

 Files modified:
  ✓ src/utils.py  (3 imports, 2 blanks)
  ✓ src/main.py   (1 imports + 2 warnings)
  ...
══════════════════════════════════════════════════

This keeps the output usable even on large codebases.


Example (single-file detailed report)

══════════════════════════════════════════
  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
══════════════════════════════════════════

Contributing

See CONTRIBUTING.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystreamliner-1.19.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pystreamliner-1.19.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file pystreamliner-1.19.0.tar.gz.

File metadata

  • Download URL: pystreamliner-1.19.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pystreamliner-1.19.0.tar.gz
Algorithm Hash digest
SHA256 de54e90bcaf7a290d175082ac289535248f69dbfdb0420b2e0481dec43d02fce
MD5 4879a733b4dec9b52aa65a700f76ce25
BLAKE2b-256 df0e0e0564dc1d9118122b147f3323b7a612a611a75575eb5cf6d4d37048412e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystreamliner-1.19.0.tar.gz:

Publisher: main.yml on Supe232323/pystreamliner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pystreamliner-1.19.0-py3-none-any.whl.

File metadata

  • Download URL: pystreamliner-1.19.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pystreamliner-1.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ace190599ab007e5287ea7d70a4d2cc68285a6cb5de25e4230a0d30bdd6103ac
MD5 e9ac7f2cdc694cd5db85401e553f214b
BLAKE2b-256 bc484c1461d0b451b71e96aa0bc5c0c90901cddcdace3805e660cb8425ab73a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pystreamliner-1.19.0-py3-none-any.whl:

Publisher: main.yml on Supe232323/pystreamliner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.21.1

2 files

1.21.0

2 files

1.20.3

2 files

1.20.2

2 files

1.20.0

2 files

1.19.1

2 files

This release

1.19.0 This release

2 files

1.18.0

2 files

1.17.0

2 files

1.16.0

2 files

1.15.0

2 files

1.14.0

2 files

1.13.1

2 files

1.12.1

2 files

1.12.0

2 files

1.11.0

2 files

1.3

2 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