Skip to main content

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

Metadata

Release files for masoumi 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for masoumi 0.2.2
File Size Uploaded Provenance Actions
masoumi-0.2.2.tar.gz 6.5 kB Without provenance Details for masoumi-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for masoumi 0.2.2
File Interpreter ABI Platform Actions
masoumi-0.2.2-py3-none-any.whl Python 3 none any Details for masoumi-0.2.2-py3-none-any.whl

Total release size: 13.3 kB

Release files / masoumi-0.2.2.tar.gz

Download URL masoumi-0.2.2.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f8c0a51879c1aca9eab5a85c1fe24056d9df56b375dc54b87c55063321f28cce
BLAKE2b-256 checksum
How to use checksums
72be02ed2abd8e7153d51688e86fbaee36bf63dd93da2ec606d5515d97102a03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / masoumi-0.2.2-py3-none-any.whl

Download URL masoumi-0.2.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1d9415894e2c89a85755c6583536b034a2ae9c945e2e79983ede817741949e8
BLAKE2b-256 checksum
How to use checksums
9b458f8af2a2ee0715d5b87957dd16c0230c3e16a8b031cfe239bd64d92f29fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for masoumi 0.2.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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