clarix 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
clarix-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kane Bean
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
clarix-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: clarix
3
+ Version: 0.1.0
4
+ Summary: A smart Python error explainer with rich UI and structured insights
5
+ Author: Kane
6
+ License: MIT
7
+ Keywords: python,debugging,error-explainer,rich,cli,developer-tools
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Debuggers
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: rich>=13.0.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: black; extra == "dev"
21
+ Requires-Dist: flake8; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ clarix
25
+ ------
26
+
27
+ clarix is a lightweight Python module for explaining and analyzing runtime errors.
28
+
29
+ Features:
30
+ - Basic error explanation interface
31
+ - Simple API for integration into projects
32
+ - Lightweight and dependency-free design
33
+
34
+ Installation:
35
+ - pip install clarix
36
+
37
+ Usage:
38
+ - import clarix
39
+ - clarix.enable()
40
+
41
+ Current Status:
42
+ - Early development version (0.0.1)
43
+ - Core functionality under expansion
44
+
45
+ Future Plans:
46
+ - Detailed error categorization
47
+ - Improved explanation engine
48
+ - Support for advanced debugging insights
clarix-0.1.0/README.md ADDED
@@ -0,0 +1,25 @@
1
+ clarix
2
+ ------
3
+
4
+ clarix is a lightweight Python module for explaining and analyzing runtime errors.
5
+
6
+ Features:
7
+ - Basic error explanation interface
8
+ - Simple API for integration into projects
9
+ - Lightweight and dependency-free design
10
+
11
+ Installation:
12
+ - pip install clarix
13
+
14
+ Usage:
15
+ - import clarix
16
+ - clarix.enable()
17
+
18
+ Current Status:
19
+ - Early development version (0.0.1)
20
+ - Core functionality under expansion
21
+
22
+ Future Plans:
23
+ - Detailed error categorization
24
+ - Improved explanation engine
25
+ - Support for advanced debugging insights
@@ -0,0 +1,5 @@
1
+ # clarix/__init__.py
2
+
3
+ from .core import enable, boot
4
+
5
+ __all__ = ["enable", "boot"]
@@ -0,0 +1,88 @@
1
+ # clarix/cli.py
2
+
3
+ import sys
4
+ import ast
5
+ import linecache
6
+ from pathlib import Path
7
+
8
+ from clarix.engine import process_exception
9
+ from clarix.ui.rich_ui import show_syntax_error, show_runtime_error
10
+
11
+
12
+ def _syntax_check(source: str, filename: str):
13
+ try:
14
+ ast.parse(source, filename=filename)
15
+ return None
16
+ except SyntaxError as err:
17
+ return err
18
+
19
+
20
+ def _get_code_line(path: Path, lineno: int):
21
+ linecache.checkcache(str(path))
22
+ return linecache.getline(str(path), lineno).rstrip()
23
+
24
+
25
+ def run_file(path_str: str):
26
+ path = Path(path_str).expanduser().resolve()
27
+
28
+ if not path.exists():
29
+ print(f"❌ File not found: {path}")
30
+ return
31
+
32
+ source = path.read_text(encoding="utf-8")
33
+
34
+ # 🔴 Phase 1: Syntax check
35
+ err = _syntax_check(source, filename=str(path))
36
+
37
+ if err:
38
+ code_line = ""
39
+
40
+ if err.lineno:
41
+ code_line = _get_code_line(path, err.lineno)
42
+
43
+ if not code_line and err.text:
44
+ code_line = err.text.rstrip()
45
+
46
+ show_syntax_error(err, path, code_line)
47
+ return
48
+
49
+ # 🟢 Phase 2: Execution
50
+ try:
51
+ code_obj = compile(source, str(path), "exec")
52
+
53
+ globals_dict = {
54
+ "__name__": "__main__",
55
+ "__file__": str(path),
56
+ "__package__": None,
57
+ }
58
+
59
+ exec(code_obj, globals_dict, globals_dict)
60
+
61
+ except Exception as exc:
62
+ tb = exc.__traceback__
63
+
64
+ # Use engine
65
+ message = process_exception(type(exc), exc, tb)
66
+
67
+ # Extract context again for display
68
+ from clarix.context import get_context
69
+ ctx = get_context(tb)
70
+
71
+ show_runtime_error(
72
+ message=message,
73
+ line=ctx.get("line"),
74
+ code=ctx.get("code"),
75
+ filename=ctx.get("filename")
76
+ )
77
+
78
+
79
+ def main():
80
+ if len(sys.argv) < 2:
81
+ print("Usage: clarix-run <file.py>")
82
+ sys.exit(1)
83
+
84
+ run_file(sys.argv[1])
85
+
86
+
87
+ if __name__ == "__main__":
88
+ main()
@@ -0,0 +1,22 @@
1
+ import linecache
2
+ import traceback
3
+
4
+
5
+ def get_context(tb):
6
+ tb_list = traceback.extract_tb(tb)
7
+ last = tb_list[-1] if tb_list else None
8
+
9
+ if not last:
10
+ return {"filename": None, "line": None, "code": None}
11
+
12
+ code = (last.line or "").strip()
13
+
14
+ if not code and last.filename and last.lineno:
15
+ linecache.checkcache(last.filename)
16
+ code = linecache.getline(last.filename, last.lineno).strip()
17
+
18
+ return {
19
+ "filename": last.filename,
20
+ "line": last.lineno,
21
+ "code": code,
22
+ }
@@ -0,0 +1,55 @@
1
+ # clarix/core.py
2
+
3
+ import sys
4
+ from .engine import process_exception
5
+ from .context import get_context
6
+ from .ui.rich_ui import show_runtime_error
7
+
8
+ _original_hook = sys.excepthook
9
+
10
+
11
+ def _hook(exc_type, exc_value, traceback):
12
+ try:
13
+ message = process_exception(exc_type, exc_value, traceback)
14
+ ctx = get_context(traceback)
15
+
16
+ show_runtime_error(
17
+ message=message,
18
+ line=ctx.get("line"),
19
+ code=ctx.get("code"),
20
+ filename=ctx.get("filename")
21
+ )
22
+
23
+ except Exception:
24
+ _original_hook(exc_type, exc_value, traceback)
25
+
26
+
27
+ def enable():
28
+ print("\n⚠️ Clarix enabled (runtime mode)")
29
+ print("💡 Syntax errors require CLI: clarix-run <file>\n")
30
+
31
+ sys.excepthook = _hook
32
+
33
+
34
+ def boot():
35
+ """
36
+ Executes the current script under Clarix control
37
+ """
38
+ import runpy
39
+
40
+ try:
41
+ runpy.run_path(sys.argv[0], run_name="__main__")
42
+
43
+ except SyntaxError as e:
44
+ print(f"""
45
+ [Notice: Future upgrade 🚧]
46
+
47
+ ⚠️ Syntax Error detected
48
+ 🧠 Clarix is improving syntax-level understanding.
49
+
50
+ 📍 Line {e.lineno}: {e.text.strip() if e.text else ''}
51
+ 🔍 Message: {e.msg}
52
+ """)
53
+
54
+ except Exception as e:
55
+ print(process_exception(type(e), e, e.__traceback__))
@@ -0,0 +1,20 @@
1
+ # clarix/engine.py
2
+
3
+ from .handlers import name_error, type_error, zero_division
4
+ from .context import get_context
5
+
6
+ def process_exception(exc_type, exc_value, tb):
7
+ context = get_context(tb)
8
+ name = exc_type.__name__
9
+
10
+ if name == "NameError":
11
+ return name_error.handle(exc_value, context)
12
+
13
+ elif name == "TypeError":
14
+ return type_error.handle(exc_value, context)
15
+
16
+ elif name == "ZeroDivisionError":
17
+ return zero_division.handle(exc_value, context)
18
+
19
+ return f"❌ {name}: {exc_value}"
20
+
@@ -0,0 +1,11 @@
1
+ # clarix/handlers/__init__.py
2
+
3
+ from . import name_error
4
+ from . import type_error
5
+ from . import zero_division
6
+
7
+ __all__ = [
8
+ "name_error",
9
+ "type_error",
10
+ "zero_division",
11
+ ]
@@ -0,0 +1,23 @@
1
+ # clarix/handlers/name_error.py
2
+
3
+ # clarix/handlers/name_error.py
4
+
5
+ import re
6
+ from ..utils.suggestions import suggest_name
7
+
8
+ def handle(exc_value, context):
9
+ msg = str(exc_value)
10
+
11
+ match = re.search(r"name '(.+)' is not defined", msg)
12
+ if not match:
13
+ return f"❌ NameError: {msg}"
14
+
15
+ var = match.group(1)
16
+ suggestion = suggest_name(var)
17
+
18
+ base = f"❌ Variable '{var}' is not defined."
19
+
20
+ if suggestion:
21
+ base += f"\n💡 Did you mean '{suggestion}'?"
22
+
23
+ return base
@@ -0,0 +1,16 @@
1
+ # clarix/handlers/type_error.py
2
+
3
+ def handle(exc_value, context):
4
+ msg = str(exc_value)
5
+
6
+ explanation = "You're trying to use incompatible data types."
7
+
8
+ if "unsupported operand" in msg:
9
+ explanation = "You tried an operation between incompatible types (e.g., string + int)."
10
+
11
+ return (
12
+ f"❌ Type Error\n"
13
+ f"🧠 {explanation}\n"
14
+ f"⚠️ {msg}"
15
+ )
16
+
@@ -0,0 +1,7 @@
1
+ # clarix/handlers/zero_division.py
2
+
3
+ def handle(exc_value, context):
4
+ return (
5
+ "❌ Division by Zero\n"
6
+ "🧠 You cannot divide a number by zero because it is undefined.\n"
7
+ )
@@ -0,0 +1,3 @@
1
+ from .rich_ui import show_syntax_error, show_runtime_error
2
+
3
+ __all__ = ["show_syntax_error", "show_runtime_error"]
@@ -0,0 +1,97 @@
1
+ from rich.console import Console
2
+ from rich.panel import Panel
3
+ from rich.text import Text
4
+ from rich.syntax import Syntax
5
+ from rich.table import Table
6
+ from rich.box import ROUNDED
7
+
8
+ console = Console()
9
+
10
+
11
+ # 🔴 SYNTAX ERROR DISPLAY
12
+ def show_syntax_error(err, path, code_line):
13
+ title = Text("⚠️ CLARIX SYNTAX ERROR", style="bold yellow")
14
+
15
+ # 📂 File Info Table (with zebra striping)
16
+ table = Table(
17
+ box=ROUNDED,
18
+ expand=True,
19
+ row_styles=["cyan", "purple"] # ← zebra stripes
20
+ )
21
+ table.add_column("Field", style="bold cyan")
22
+ table.add_column("Value", style="white")
23
+
24
+ table.add_row("File", str(path))
25
+ table.add_row("Line", str(err.lineno))
26
+ table.add_row("Error", err.msg)
27
+
28
+ # 💻 Highlighted Code
29
+ syntax = Syntax(
30
+ code_line,
31
+ "python",
32
+ theme="monokai",
33
+ line_numbers=False
34
+ )
35
+
36
+ # 🧠 Insight Text
37
+ insight = Text(
38
+ "\nThis error occurs before execution (parsing stage).\n"
39
+ "Likely causes: typo, missing operator, or invalid syntax.",
40
+ style="italic dim"
41
+ )
42
+
43
+ panel = Panel(
44
+ table,
45
+ title=title,
46
+ border_style="yellow",
47
+ padding=(1, 2)
48
+ )
49
+
50
+ console.print(panel)
51
+ console.print("\n💻 Buggy Line:\n", syntax)
52
+ console.print(insight)
53
+
54
+
55
+ # 🔴 RUNTIME ERROR DISPLAY
56
+ def show_runtime_error(message, line=None, code=None, filename=None):
57
+ title = Text("❌ CLARIX RUNTIME ERROR", style="bold red")
58
+
59
+ # 📂 Info Table (with zebra striping)
60
+ table = Table(
61
+ box=ROUNDED,
62
+ expand=True,
63
+ row_styles=["cyan", "purple"] # ← zebra stripes
64
+ )
65
+ table.add_column("Field", style="bold magenta")
66
+ table.add_column("Value", style="white")
67
+
68
+ if filename:
69
+ table.add_row("File", str(filename))
70
+ if line:
71
+ table.add_row("Line", str(line))
72
+
73
+ # 💻 Code Highlight
74
+ syntax_block = None
75
+ if code:
76
+ syntax_block = Syntax(
77
+ code,
78
+ "python",
79
+ theme="monokai",
80
+ line_numbers=False
81
+ )
82
+
83
+ # 🧠 Main Message
84
+ message_text = Text(message, style="bold")
85
+
86
+ panel = Panel(
87
+ table,
88
+ title=title,
89
+ border_style="red",
90
+ padding=(1, 2)
91
+ )
92
+
93
+ console.print(panel)
94
+ console.print("\n🧠 Explanation:\n", message_text)
95
+
96
+ if syntax_block:
97
+ console.print("\n💻 Buggy Line:\n", syntax_block)
@@ -0,0 +1,5 @@
1
+ # clarix/utils/__init__.py
2
+
3
+ from .suggestions import suggest_name
4
+
5
+ __all__ = ["suggest_name"]
@@ -0,0 +1,20 @@
1
+ # clarix/utils/parser.py
2
+
3
+ import re
4
+
5
+ def extract_name_error(msg):
6
+ match = re.search(r"name '(.+)' is not defined", msg)
7
+ return match.group(1) if match else None
8
+
9
+
10
+ def extract_type_error_operands(msg):
11
+ match = re.search(r"unsupported operand type\(s\) for (.+): '(.+)' and '(.+)'", msg)
12
+
13
+ if match:
14
+ return {
15
+ "operator": match.group(1),
16
+ "left": match.group(2),
17
+ "right": match.group(3),
18
+ }
19
+
20
+ return None
@@ -0,0 +1,10 @@
1
+ # clarix/utils/suggestions.py
2
+
3
+ import difflib
4
+ import builtins
5
+
6
+ def suggest_name(name):
7
+ pool = dir(builtins)
8
+
9
+ matches = difflib.get_close_matches(name, pool, n=1)
10
+ return matches[0] if matches else None
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: clarix
3
+ Version: 0.1.0
4
+ Summary: A smart Python error explainer with rich UI and structured insights
5
+ Author: Kane
6
+ License: MIT
7
+ Keywords: python,debugging,error-explainer,rich,cli,developer-tools
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Debuggers
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: rich>=13.0.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest; extra == "dev"
20
+ Requires-Dist: black; extra == "dev"
21
+ Requires-Dist: flake8; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ clarix
25
+ ------
26
+
27
+ clarix is a lightweight Python module for explaining and analyzing runtime errors.
28
+
29
+ Features:
30
+ - Basic error explanation interface
31
+ - Simple API for integration into projects
32
+ - Lightweight and dependency-free design
33
+
34
+ Installation:
35
+ - pip install clarix
36
+
37
+ Usage:
38
+ - import clarix
39
+ - clarix.enable()
40
+
41
+ Current Status:
42
+ - Early development version (0.0.1)
43
+ - Core functionality under expansion
44
+
45
+ Future Plans:
46
+ - Detailed error categorization
47
+ - Improved explanation engine
48
+ - Support for advanced debugging insights
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ clarix/__init__.py
5
+ clarix/cli.py
6
+ clarix/context.py
7
+ clarix/core.py
8
+ clarix/engine.py
9
+ clarix.egg-info/PKG-INFO
10
+ clarix.egg-info/SOURCES.txt
11
+ clarix.egg-info/dependency_links.txt
12
+ clarix.egg-info/entry_points.txt
13
+ clarix.egg-info/requires.txt
14
+ clarix.egg-info/top_level.txt
15
+ clarix/handlers/__init__.py
16
+ clarix/handlers/name_error.py
17
+ clarix/handlers/type_error.py
18
+ clarix/handlers/zero_division.py
19
+ clarix/ui/__init__.py
20
+ clarix/ui/rich_ui.py
21
+ clarix/utils/__init__.py
22
+ clarix/utils/parser.py
23
+ clarix/utils/suggestions.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ clarix-run = clarix.cli:main
@@ -0,0 +1,6 @@
1
+ rich>=13.0.0
2
+
3
+ [dev]
4
+ pytest
5
+ black
6
+ flake8
@@ -0,0 +1 @@
1
+ clarix
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+
6
+ [project]
7
+ name = "clarix"
8
+ version = "0.1.0"
9
+ description = "A smart Python error explainer with rich UI and structured insights"
10
+ readme = "README.md"
11
+ authors = [
12
+ { name = "Kane" }
13
+ ]
14
+ license = { text = "MIT" }
15
+ requires-python = ">=3.8"
16
+
17
+ keywords = ["python", "debugging", "error-explainer", "rich", "cli", "developer-tools"]
18
+
19
+ classifiers = [
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Intended Audience :: Developers",
25
+ "Topic :: Software Development :: Debuggers",
26
+ ]
27
+
28
+
29
+ dependencies = [
30
+ "rich>=13.0.0"
31
+ ]
32
+
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "pytest",
37
+ "black",
38
+ "flake8"
39
+ ]
40
+
41
+
42
+ [project.scripts]
43
+ clarix-run = "clarix.cli:main"
44
+
45
+
46
+ [tool.setuptools.packages.find]
47
+ where = ["."]
48
+ include = ["clarix*"]
49
+
50
+
51
+ [tool.setuptools.package-data]
52
+ clarix = ["*.txt", "*.md"]
clarix-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+