Python developer toolkit — performance analyzer and more
Project description
masoumi
Python developer toolkit — performance analyzer and more.
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.1.tar.gz
(6.8 kB
view details)
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 masoumi-0.2.1.tar.gz.
File metadata
- Download URL: masoumi-0.2.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60f23013632084e06635c4563bf85ad7647bbc47200220b362eed8031d8927b2
|
|
| MD5 |
03fc3ba02178940df7118a39965996d9
|
|
| BLAKE2b-256 |
afba79e5f77b5cb73b83b7f80aee4cea4fb5d7d886622ddad8537170c8f1c60f
|
File details
Details for the file masoumi-0.2.1-py3-none-any.whl.
File metadata
- Download URL: masoumi-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8907e5ef11c141b055ca55b9436f3e4519b37cb7fc6ba79309e732bd6078413
|
|
| MD5 |
27dc3c41899b3592ad048de286f76ca8
|
|
| BLAKE2b-256 |
aea3900512b5d7ef43567b64cbd808f93d51aa7d4d38a4dd4fb8d576c1b6691f
|