Skip to main content

Assign emotional personalities to Python functions via AST + runtime analysis

Project description

emotion-ai logo

emotion

Give your Python functions feelings.
A Python decorator that assigns emotional personalities to functions based on code structure and runtime behaviour.


What It Does

Feature Description
🎭 Emotion assignment Each function gets an emotion based on its code structure: complexity, keywords, recursion, async, error-handling, etc.
🌈 Rich colorful CLI Every call prints ANSI 256-color output: emotion chip, intensity bar, valence badge, wall time, CPU time, memory, error count
💬 Inter-function conversation When two conversation=True functions run concurrently, they talk to each other in the terminal
🔄 Emotion drift Emotions evolve every 10 calls based on error rate, latency, and frequency
🤝 Social relationships Functions develop feelings toward each other: friendship, jealousy, respect, anger, pity…
🔬 Deep profiling Wall time, CPU time, heap delta, heap peak via tracemalloc — O(1) overhead per call
🕸️ Call graph Static AST scan builds a project-wide call graph; see who calls whom

Quick Demo

from checkemotion import emotion

@emotion
def calculate_total(numbers: list) -> float:
    return sum(n for n in numbers if n > 0)

@emotion(conversation=True)
def validate_user(user_id: int, role: str) -> bool:
    try:
        assert user_id > 0
        assert role.strip()
        return True
    except AssertionError:
        return False

calculate_total([1, 2, 3, 4, 5])
validate_user(42, "admin")

Terminal output:

  😊  calculate_total  ▸  glad  [joy]  ░····  ▲ +
    ▸ awakened  Sums positive numbers and returns the total.

  │ ✓ done  😊 calculate_total  #1  ⏱ 0.1ms  cpu 0.01ms  mem +0.0KB  cc=2  err=0

Installation

pip install checkemotion

Or clone and run directly:

git clone https://github.com/itsmohitrohilla/emotion.git
cd emotion
python examples/quickstart.py

The @emotion Decorator

# Bare — simplest form
@emotion
def my_function(x):
    return x * 2

# With options
@emotion(enabled=True, conversation=True, verbose=True)
def my_function(x):
    return x * 2
Option Default Description
enabled True False → zero overhead, function unchanged
conversation False Functions talk to each other when running concurrently
verbose True False → silent mode, metrics still collected

Public API

from checkemotion import (
    emotion,              # decorator
    build_report,         # build_report(name) → FunctionReport
    all_reports,          # all_reports(sort_by="call_count") → list
    describe,             # describe(func) → one-line string
    callers_of,           # callers_of(name) → list of caller names
    callees_of,           # callees_of(name) → list of callee names
    scan_directory,       # scan_directory(path) → build call graph
    get_all_names,        # list of all registered function names
    get_data,             # get_data(name) → raw registry dict
)

Requirements

  • Python 3.11+
  • Zero external dependencies — pure stdlib
  • Optional: Ollama with phi3.5:mini for AI-generated descriptions

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

checkemotion-0.2.2.tar.gz (81.9 kB view details)

Uploaded Source

Built Distribution

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

checkemotion-0.2.2-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for checkemotion-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e4ef8a127db7c99e25e27e1d085c81642e2812d5e87b019cec7f21c03b10a6e2
MD5 5728e6026b1225e4836bc0ccaf787f71
BLAKE2b-256 ae7490c1acbaa6bf94b46f48587e921625a6b03d7652a801b2875a0245bcc1f6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for checkemotion-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec016820c432edb21eb1e881c1a074667e0a6e6f60929975ac5aa6647aec6e7
MD5 12d7966c164d64268d7627e77169486a
BLAKE2b-256 64903f55fd6f6d989eccb2041a8fcb026706b9696e7f715d61ea1c4d6edbdb61

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