Skip to main content

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.0.tar.gz (6.4 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.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: masoumi-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 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.0.tar.gz
Algorithm Hash digest
SHA256 ae74a56e65754f1a75e20cdd2dbde9864c17de9a21a85bb4f7c93d1586d7119d
MD5 82fe194dfbcfae95599f70e13bd1d426
BLAKE2b-256 af9eab631159dc0cc40fae8b954d86600627f534542cf004ed80c2692ba58f4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: masoumi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adc2096858549bc45bad87b65a43ab224e8062931632b25979116e79f16d2c36
MD5 21caa590f44677505fad82f92fdc2b24
BLAKE2b-256 4463ec74c729481c25f7ca85b1c79065f2f31278e372d45bebcbab5992026ca4

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