clarix 0.0.2__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.0.2/LICENSE +21 -0
- clarix-0.0.2/PKG-INFO +48 -0
- clarix-0.0.2/README.md +25 -0
- clarix-0.0.2/clarix/__init__.py +187 -0
- clarix-0.0.2/clarix/cli.py +16 -0
- clarix-0.0.2/clarix/context.py +22 -0
- clarix-0.0.2/clarix/core.py +55 -0
- clarix-0.0.2/clarix/engine.py +20 -0
- clarix-0.0.2/clarix/handlers/__init__.py +11 -0
- clarix-0.0.2/clarix/handlers/name_error.py +23 -0
- clarix-0.0.2/clarix/handlers/type_error.py +16 -0
- clarix-0.0.2/clarix/handlers/zero_division.py +7 -0
- clarix-0.0.2/clarix/ui/__init__.py +3 -0
- clarix-0.0.2/clarix/ui/rich_ui.py +97 -0
- clarix-0.0.2/clarix/utils/__init__.py +5 -0
- clarix-0.0.2/clarix/utils/parser.py +20 -0
- clarix-0.0.2/clarix/utils/suggestions.py +10 -0
- clarix-0.0.2/clarix.egg-info/PKG-INFO +48 -0
- clarix-0.0.2/clarix.egg-info/SOURCES.txt +23 -0
- clarix-0.0.2/clarix.egg-info/dependency_links.txt +1 -0
- clarix-0.0.2/clarix.egg-info/entry_points.txt +2 -0
- clarix-0.0.2/clarix.egg-info/requires.txt +6 -0
- clarix-0.0.2/clarix.egg-info/top_level.txt +1 -0
- clarix-0.0.2/pyproject.toml +52 -0
- clarix-0.0.2/setup.cfg +4 -0
clarix-0.0.2/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.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clarix
|
|
3
|
+
Version: 0.0.2
|
|
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.0.2/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,187 @@
|
|
|
1
|
+
# clarix/__init__.py
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
CLARIX — Python Error Explanation Engine
|
|
5
|
+
========================================
|
|
6
|
+
|
|
7
|
+
Overview
|
|
8
|
+
--------
|
|
9
|
+
Clarix is a developer-focused utility designed to analyze Python exceptions
|
|
10
|
+
and present them in a structured, human-readable format. It enhances debugging
|
|
11
|
+
by transforming raw error traces into clear explanations with contextual hints.
|
|
12
|
+
|
|
13
|
+
The system is particularly useful for beginners, learners, and rapid development
|
|
14
|
+
environments where understanding errors efficiently is critical.
|
|
15
|
+
|
|
16
|
+
------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
Installation
|
|
19
|
+
------------
|
|
20
|
+
Install Clarix via pip:
|
|
21
|
+
|
|
22
|
+
pip install clarix
|
|
23
|
+
|
|
24
|
+
Ensure Python version compatibility before installation.
|
|
25
|
+
|
|
26
|
+
------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
Quick Start
|
|
29
|
+
-----------
|
|
30
|
+
There are two primary ways to use Clarix:
|
|
31
|
+
|
|
32
|
+
1. Command-Line Interface (CLI)
|
|
33
|
+
|
|
34
|
+
clarix-run <file.py>
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
|
|
38
|
+
clarix-run test.py
|
|
39
|
+
|
|
40
|
+
This will execute the script and display formatted error output
|
|
41
|
+
if an exception occurs.
|
|
42
|
+
|
|
43
|
+
2. Programmatic Usage
|
|
44
|
+
|
|
45
|
+
import clarix
|
|
46
|
+
clarix.run("<folder/file.py>")
|
|
47
|
+
|
|
48
|
+
You may also pass file paths explicitly.
|
|
49
|
+
|
|
50
|
+
------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
Core Features
|
|
53
|
+
-------------
|
|
54
|
+
• Structured Error Display
|
|
55
|
+
Errors are presented using formatted tables and panels for clarity.
|
|
56
|
+
|
|
57
|
+
• Syntax Highlighting
|
|
58
|
+
Relevant code sections are displayed with visual emphasis.
|
|
59
|
+
|
|
60
|
+
• Contextual Explanation
|
|
61
|
+
Provides simplified explanations of Python errors.
|
|
62
|
+
|
|
63
|
+
• File and Line Tracking
|
|
64
|
+
Displays exact file name and line number where the error occurred.
|
|
65
|
+
|
|
66
|
+
• Enhanced Readability
|
|
67
|
+
Uses styled output (via rich formatting) to improve debugging experience.
|
|
68
|
+
|
|
69
|
+
------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
Supported Error Types
|
|
72
|
+
---------------------
|
|
73
|
+
Clarix currently supports analysis of common Python exceptions, including:
|
|
74
|
+
|
|
75
|
+
• SyntaxError
|
|
76
|
+
• NameError
|
|
77
|
+
• TypeError
|
|
78
|
+
• ValueError
|
|
79
|
+
• IndexError
|
|
80
|
+
• KeyError
|
|
81
|
+
|
|
82
|
+
Support for additional error types may be added in future releases.
|
|
83
|
+
|
|
84
|
+
------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
Versioning
|
|
87
|
+
----------
|
|
88
|
+
Clarix follows semantic versioning:
|
|
89
|
+
|
|
90
|
+
MAJOR.MINOR.PATCH
|
|
91
|
+
|
|
92
|
+
• PATCH: Bug fixes
|
|
93
|
+
• MINOR: New features (backward-compatible)
|
|
94
|
+
• MAJOR: Breaking changes
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
|
|
98
|
+
0.1.0 → Initial release
|
|
99
|
+
0.1.1 → Bug fix
|
|
100
|
+
0.2.0 → Feature addition
|
|
101
|
+
|
|
102
|
+
------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
Updating Clarix
|
|
105
|
+
---------------
|
|
106
|
+
To update to the latest version:
|
|
107
|
+
|
|
108
|
+
pip install --upgrade clarix
|
|
109
|
+
|
|
110
|
+
Ensure your environment has internet access and appropriate permissions.
|
|
111
|
+
|
|
112
|
+
------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
Design Philosophy
|
|
115
|
+
-----------------
|
|
116
|
+
Clarix is built on the principle that debugging should be intuitive.
|
|
117
|
+
Instead of forcing developers to interpret dense tracebacks, the tool
|
|
118
|
+
acts as an interpreter layer—translating machine-level exceptions into
|
|
119
|
+
human-level understanding.
|
|
120
|
+
|
|
121
|
+
------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
Limitations
|
|
124
|
+
-----------
|
|
125
|
+
• Does not replace Python's native traceback system
|
|
126
|
+
• Complex runtime errors may still require manual inspection
|
|
127
|
+
• Dependent on correct environment configuration
|
|
128
|
+
|
|
129
|
+
------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
Best Practices
|
|
132
|
+
--------------
|
|
133
|
+
• Use Clarix during development, not in production pipelines
|
|
134
|
+
• Combine with logging for deeper debugging workflows
|
|
135
|
+
• Regularly update to access improved explanations
|
|
136
|
+
|
|
137
|
+
------------------------------------------------------------
|
|
138
|
+
|
|
139
|
+
Future Enhancements (Planned)
|
|
140
|
+
----------------------------
|
|
141
|
+
• Support for more exception types
|
|
142
|
+
• Integration with IDEs
|
|
143
|
+
• Auto-update notifications
|
|
144
|
+
|
|
145
|
+
------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
Author
|
|
148
|
+
------
|
|
149
|
+
Developed as an independent Python utility project.
|
|
150
|
+
|
|
151
|
+
------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
License
|
|
154
|
+
-------
|
|
155
|
+
MIT License
|
|
156
|
+
|
|
157
|
+
Copyright (c) 2026 Kane Bean
|
|
158
|
+
|
|
159
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
160
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
161
|
+
in the Software without restriction, including without limitation the rights
|
|
162
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
163
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
164
|
+
furnished to do so, subject to the following conditions:
|
|
165
|
+
|
|
166
|
+
The above copyright notice and this permission notice shall be included in all
|
|
167
|
+
copies or substantial portions of the Software.
|
|
168
|
+
|
|
169
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
170
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
171
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
172
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
173
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
174
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
175
|
+
SOFTWARE.
|
|
176
|
+
|
|
177
|
+
------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
End of Manual
|
|
180
|
+
-------------
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
from .core import enable, boot
|
|
184
|
+
from .core import enable
|
|
185
|
+
from .runner import run
|
|
186
|
+
|
|
187
|
+
__all__ = ["enable", "run" , "boot"]
|
|
@@ -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,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,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,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,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clarix
|
|
3
|
+
Version: 0.0.2
|
|
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 @@
|
|
|
1
|
+
|
|
@@ -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.0.2"
|
|
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.0.2/setup.cfg
ADDED