Assign emotional personalities to Python functions via AST + runtime analysis
Project description
Check 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
Project details
Release history Release notifications | RSS feed
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.3.tar.gz
(81.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 checkemotion-0.2.3.tar.gz.
File metadata
- Download URL: checkemotion-0.2.3.tar.gz
- Upload date:
- Size: 81.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c2e4969dcfe4dd43ef6072b262145c3a07cb82260ede25f9de0f7b1a3dd0dc3
|
|
| MD5 |
aa02cd8702bc9fd7fcef0e60fa5d57e2
|
|
| BLAKE2b-256 |
21b3438a1ff1793456413a67f98e7b730890c08cb4eb2f8abe59caed1b808750
|
File details
Details for the file checkemotion-0.2.3-py3-none-any.whl.
File metadata
- Download URL: checkemotion-0.2.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de3c0fad42526a4c8caab9f6300ac4b74bca6a717a206575d8ab3de812fc44e9
|
|
| MD5 |
0967c2e01c436a7adff727611b14b097
|
|
| BLAKE2b-256 |
5d184e8edb4c10d17d09ab44e60f4dcb7a828e68ee7c2f9b3f30caa32b9c5473
|