Skip to main content

Python developer toolkit — performance analyzer and more

Project description

masoumi

Python developer toolkit — performance analyzer and more.

▶️ Watch demo on GitHub

Install

pip install masoumi

Usage

import masoumi

code = open("my_script.py").read()

# Analyze full file
issues = masoumi.analyze(code)

# Analyze specific line range
issues = masoumi.analyze(code, start=10, end=50)

# Analyze a file directly
issues = masoumi.analyze_file("my_script.py", start=1, end=100)

# Use in CI/CD — no print, just data
issues = masoumi.analyze(code, print_report=False)
high = [i for i in issues if i.severity == "HIGH"]
if high:
    raise SystemExit(f"{len(high)} high severity issue(s) found.")

# Get results as plain dicts (for JSON, logging, etc.)
data = masoumi.issues_as_dicts(issues)

# Enable runtime profiling (executes your code — use on trusted scripts only)
issues = masoumi.analyze(code, runtime=True)

What it detects

Severity Issue
🔴 HIGH String concatenation += inside loops
🔴 HIGH Mutable default argument (list, dict, set)
🟡 MEDIUM Nested loops (O(n²) complexity warning)
🟡 MEDIUM list.append() inside loop (use comprehension)
🟡 MEDIUM in lookup on list/tuple instead of set
🟡 MEDIUM Bare except: clause
🟡 MEDIUM Recursive function without clear base case
🟡 MEDIUM global variable usage
🔵 LOW Unnecessary pass statements
🔵 LOW Imports inside functions
🔵 LOW Functions with too many parameters (>7)
🟣 PROFILE Slow functions — runtime profiling (runtime=True)

Return value

analyze() and analyze_file() return a list[Issue].
Each Issue has:

issue.line      # int — line number
issue.severity  # str — "HIGH" / "MEDIUM" / "LOW" / "PROFILE"
issue.message   # str — what was detected
issue.tip       # str — how to fix it
issue.code      # str — the offending line of code
issue.to_dict() # dict — all of the above as a plain dict

CI/CD example

python -c "
import masoumi, sys
issues = masoumi.analyze_file('my_script.py', print_report=True)
if any(i.severity == 'HIGH' for i in issues):
    sys.exit(1)
"

License

MIT

Project details


Download files

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

Source Distribution

masoumi-0.2.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

masoumi-0.2.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file masoumi-0.2.2.tar.gz.

File metadata

  • Download URL: masoumi-0.2.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for masoumi-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f8c0a51879c1aca9eab5a85c1fe24056d9df56b375dc54b87c55063321f28cce
MD5 66af65e7a27b628b6486c78b258bf88a
BLAKE2b-256 72be02ed2abd8e7153d51688e86fbaee36bf63dd93da2ec606d5515d97102a03

See more details on using hashes here.

File details

Details for the file masoumi-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: masoumi-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for masoumi-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1d9415894e2c89a85755c6583536b034a2ae9c945e2e79983ede817741949e8
MD5 fa06793f0a4146ff76d287a26502205f
BLAKE2b-256 9b458f8af2a2ee0715d5b87957dd16c0230c3e16a8b031cfe239bd64d92f29fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page