debug-dojo 0.4.1__tar.gz → 0.6.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.
- debug_dojo-0.6.0/LICENSE +21 -0
- debug_dojo-0.6.0/PKG-INFO +137 -0
- debug_dojo-0.6.0/README.md +105 -0
- debug_dojo-0.6.0/pyproject.toml +142 -0
- debug_dojo-0.6.0/setup.cfg +4 -0
- debug_dojo-0.6.0/src/debug_dojo/_cli.py +192 -0
- debug_dojo-0.4.1/src/debug_dojo/_compareres.py → debug_dojo-0.6.0/src/debug_dojo/_compare.py +23 -18
- debug_dojo-0.6.0/src/debug_dojo/_config.py +198 -0
- {debug_dojo-0.4.1 → debug_dojo-0.6.0}/src/debug_dojo/_config_models.py +82 -45
- debug_dojo-0.6.0/src/debug_dojo/_installers.py +253 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/PKG-INFO +137 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/SOURCES.txt +21 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/dependency_links.txt +1 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/entry_points.txt +2 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/requires.txt +7 -0
- debug_dojo-0.6.0/src/debug_dojo.egg-info/top_level.txt +1 -0
- debug_dojo-0.6.0/tests/test_compare.py +75 -0
- debug_dojo-0.6.0/tests/test_config.py +81 -0
- debug_dojo-0.6.0/tests/test_installers.py +161 -0
- debug_dojo-0.4.1/.gitignore +0 -209
- debug_dojo-0.4.1/PKG-INFO +0 -125
- debug_dojo-0.4.1/README.md +0 -49
- debug_dojo-0.4.1/pyproject.toml +0 -101
- debug_dojo-0.4.1/src/debug_dojo/_cli.py +0 -123
- debug_dojo-0.4.1/src/debug_dojo/_config.py +0 -136
- debug_dojo-0.4.1/src/debug_dojo/_installers.py +0 -176
- {debug_dojo-0.4.1 → debug_dojo-0.6.0}/src/debug_dojo/__init__.py +0 -0
- {debug_dojo-0.4.1 → debug_dojo-0.6.0}/src/debug_dojo/__main__.py +0 -0
- {debug_dojo-0.4.1 → debug_dojo-0.6.0}/src/debug_dojo/install.py +0 -0
- {debug_dojo-0.4.1 → debug_dojo-0.6.0}/src/debug_dojo/py.typed +0 -0
debug_dojo-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 to bwrob.
|
|
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.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: debug-dojo
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: 🏣 debug dojo, a place for zen debugging
|
|
5
|
+
Author-email: bwrob <bartosz.marcin.wroblewski@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Changelog, https://bwrob.github.io/debug-dojo/changelog/
|
|
8
|
+
Project-URL: Documentation, https://bwrob.github.io/debug-dojo/
|
|
9
|
+
Project-URL: Homepage, https://bwrob.github.io/debug-dojo/
|
|
10
|
+
Project-URL: Source, https://github.com/bwrob/debug-dojo/
|
|
11
|
+
Keywords: debugging,inspection,tools,development
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: <3.15,>=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: dacite>=1.0.0
|
|
25
|
+
Requires-Dist: debugpy>=1.0.0
|
|
26
|
+
Requires-Dist: ipdb>=0.12.0
|
|
27
|
+
Requires-Dist: pudb>=2019.1
|
|
28
|
+
Requires-Dist: rich>=10.0.0
|
|
29
|
+
Requires-Dist: tomlkit>=0.7.0
|
|
30
|
+
Requires-Dist: typer>=0.3.0
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# debug dojo
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="https://github.com/bwrob/debug-dojo/blob/main/docs/logo/logo_python.png?raw=true" alt="debug dojo" style="width:50%; max-width:350px;"/>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<em>🏣 debug dojo, a place for zen debugging</em>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<a href="https://pypi.org/project/debug-dojo">
|
|
45
|
+
<img src="https://img.shields.io/pypi/v/debug-dojo.svg?style=flat-square" alt="PyPi Version">
|
|
46
|
+
</a>
|
|
47
|
+
<a href="https://pypi.org/pypi/debug-dojo/">
|
|
48
|
+
<img src="https://img.shields.io/pypi/pyversions/debug-dojo.svg?style=flat-square" alt="PyPI pyversions">
|
|
49
|
+
</a>
|
|
50
|
+
<a href="https://pepy.tech/project/debug-dojo">
|
|
51
|
+
<img src="https://static.pepy.tech/badge/debug-dojo/month" alt="downloads">
|
|
52
|
+
</a>
|
|
53
|
+
<a href="https://github.com/bwrob/debug-dojo/blob/main/LICENSE">
|
|
54
|
+
<img src="https://img.shields.io/github/license/bwrob/debug-dojo.svg" alt="license">
|
|
55
|
+
</a>
|
|
56
|
+
<a href="https://results.pre-commit.ci/latest/github/bwrob/debug-dojo/main">
|
|
57
|
+
<img src="https://results.pre-commit.ci/badge/github/bwrob/debug-dojo/main.svg" alt="pre-commit.ci status">
|
|
58
|
+
</a>
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
[**debug-dojo**](https://bwrob.github.io/debug-dojo/) is a powerful Python package designed to streamline your debugging workflow directly from the terminal. It integrates seamlessly with popular debuggers and enhances your inspection capabilities with beautiful, readable output.
|
|
62
|
+
|
|
63
|
+
## ✨ Features
|
|
64
|
+
|
|
65
|
+
* **Unified Debugging Interface:** Easily launch your scripts or modules with your preferred debugger (`debugpy`, `pudb`, `pdb`, `ipdb`).
|
|
66
|
+
* **Enhanced Output with Rich:** Leverages [`rich`](https://github.com/Textualize/rich) for stunning, syntax-highlighted code, pretty-printed objects, and improved tracebacks.
|
|
67
|
+
* **Side-by-Side Object Comparison:** Quickly identify differences between two Python objects.
|
|
68
|
+
* **Interactive Object Inspection:** Dive deep into object structures with a powerful `inspect` utility.
|
|
69
|
+
* **Simplified Breakpoints:** Set breakpoints effortlessly with a concise helper function.
|
|
70
|
+
|
|
71
|
+
## 🚀 Installation
|
|
72
|
+
|
|
73
|
+
Install `debug-dojo` using `pip`:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install debug-dojo
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For full debugger support, you might want to install optional dependencies:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install "debug-dojo[all]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 💻 CLI Usage
|
|
86
|
+
|
|
87
|
+
Run your Python script or module with `debug-dojo`:
|
|
88
|
+
|
|
89
|
+
```console
|
|
90
|
+
dojo my_script.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Specify a debugger, configuration file, or enable verbose output:
|
|
94
|
+
|
|
95
|
+
```console
|
|
96
|
+
dojo --debugger ipdb --config dojo.toml --verbose --module my_module
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Run an executable command with debugging tools:
|
|
100
|
+
|
|
101
|
+
```console
|
|
102
|
+
dojo --exec pytest
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 🐍 Usage in Code
|
|
106
|
+
|
|
107
|
+
Integrate `debug-dojo` directly into your Python code for on-demand debugging and inspection utilities:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import debug_dojo.install
|
|
111
|
+
|
|
112
|
+
# Set a breakpoint and enter the debugger
|
|
113
|
+
# debug_dojo.install.b() # Equivalent to breakpoint()
|
|
114
|
+
|
|
115
|
+
object_1 = {"foo": 1, "bar": 2}
|
|
116
|
+
object_2 = [1, 2, 3]
|
|
117
|
+
|
|
118
|
+
# Pretty print an object with Rich
|
|
119
|
+
debug_dojo.install.p(object_1)
|
|
120
|
+
|
|
121
|
+
# Inspect an object using Rich
|
|
122
|
+
debug_dojo.install.i(object_1)
|
|
123
|
+
|
|
124
|
+
# Compare two objects side-by-side
|
|
125
|
+
debug_dojo.install.c(object_1, object_2)
|
|
126
|
+
|
|
127
|
+
# Enter the debugger (e.g., ipdb, pudb, pdb, debugpy based on config)
|
|
128
|
+
# debug_dojo.install.b()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 📚 Documentation
|
|
132
|
+
|
|
133
|
+
For comprehensive instructions on installation, configuration, advanced usage, and API reference, please visit the [official documentation](https://bwrob.github.io/debug-dojo/).
|
|
134
|
+
|
|
135
|
+
## 🤝 Contributing
|
|
136
|
+
|
|
137
|
+
Contributions are welcome! Please refer to the [development guidelines](https://bwrob.github.io/debug-dojo/development/) for details on how to set up your development environment and submit changes.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# debug dojo
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://github.com/bwrob/debug-dojo/blob/main/docs/logo/logo_python.png?raw=true" alt="debug dojo" style="width:50%; max-width:350px;"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>🏣 debug dojo, a place for zen debugging</em>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://pypi.org/project/debug-dojo">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/debug-dojo.svg?style=flat-square" alt="PyPi Version">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://pypi.org/pypi/debug-dojo/">
|
|
16
|
+
<img src="https://img.shields.io/pypi/pyversions/debug-dojo.svg?style=flat-square" alt="PyPI pyversions">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://pepy.tech/project/debug-dojo">
|
|
19
|
+
<img src="https://static.pepy.tech/badge/debug-dojo/month" alt="downloads">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://github.com/bwrob/debug-dojo/blob/main/LICENSE">
|
|
22
|
+
<img src="https://img.shields.io/github/license/bwrob/debug-dojo.svg" alt="license">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://results.pre-commit.ci/latest/github/bwrob/debug-dojo/main">
|
|
25
|
+
<img src="https://results.pre-commit.ci/badge/github/bwrob/debug-dojo/main.svg" alt="pre-commit.ci status">
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
[**debug-dojo**](https://bwrob.github.io/debug-dojo/) is a powerful Python package designed to streamline your debugging workflow directly from the terminal. It integrates seamlessly with popular debuggers and enhances your inspection capabilities with beautiful, readable output.
|
|
30
|
+
|
|
31
|
+
## ✨ Features
|
|
32
|
+
|
|
33
|
+
* **Unified Debugging Interface:** Easily launch your scripts or modules with your preferred debugger (`debugpy`, `pudb`, `pdb`, `ipdb`).
|
|
34
|
+
* **Enhanced Output with Rich:** Leverages [`rich`](https://github.com/Textualize/rich) for stunning, syntax-highlighted code, pretty-printed objects, and improved tracebacks.
|
|
35
|
+
* **Side-by-Side Object Comparison:** Quickly identify differences between two Python objects.
|
|
36
|
+
* **Interactive Object Inspection:** Dive deep into object structures with a powerful `inspect` utility.
|
|
37
|
+
* **Simplified Breakpoints:** Set breakpoints effortlessly with a concise helper function.
|
|
38
|
+
|
|
39
|
+
## 🚀 Installation
|
|
40
|
+
|
|
41
|
+
Install `debug-dojo` using `pip`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install debug-dojo
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For full debugger support, you might want to install optional dependencies:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install "debug-dojo[all]"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 💻 CLI Usage
|
|
54
|
+
|
|
55
|
+
Run your Python script or module with `debug-dojo`:
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
dojo my_script.py
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Specify a debugger, configuration file, or enable verbose output:
|
|
62
|
+
|
|
63
|
+
```console
|
|
64
|
+
dojo --debugger ipdb --config dojo.toml --verbose --module my_module
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Run an executable command with debugging tools:
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
dojo --exec pytest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 🐍 Usage in Code
|
|
74
|
+
|
|
75
|
+
Integrate `debug-dojo` directly into your Python code for on-demand debugging and inspection utilities:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import debug_dojo.install
|
|
79
|
+
|
|
80
|
+
# Set a breakpoint and enter the debugger
|
|
81
|
+
# debug_dojo.install.b() # Equivalent to breakpoint()
|
|
82
|
+
|
|
83
|
+
object_1 = {"foo": 1, "bar": 2}
|
|
84
|
+
object_2 = [1, 2, 3]
|
|
85
|
+
|
|
86
|
+
# Pretty print an object with Rich
|
|
87
|
+
debug_dojo.install.p(object_1)
|
|
88
|
+
|
|
89
|
+
# Inspect an object using Rich
|
|
90
|
+
debug_dojo.install.i(object_1)
|
|
91
|
+
|
|
92
|
+
# Compare two objects side-by-side
|
|
93
|
+
debug_dojo.install.c(object_1, object_2)
|
|
94
|
+
|
|
95
|
+
# Enter the debugger (e.g., ipdb, pudb, pdb, debugpy based on config)
|
|
96
|
+
# debug_dojo.install.b()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 📚 Documentation
|
|
100
|
+
|
|
101
|
+
For comprehensive instructions on installation, configuration, advanced usage, and API reference, please visit the [official documentation](https://bwrob.github.io/debug-dojo/).
|
|
102
|
+
|
|
103
|
+
## 🤝 Contributing
|
|
104
|
+
|
|
105
|
+
Contributions are welcome! Please refer to the [development guidelines](https://bwrob.github.io/debug-dojo/development/) for details on how to set up your development environment and submit changes.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
authors = [ { name = "bwrob", email = "bartosz.marcin.wroblewski@gmail.com" } ]
|
|
3
|
+
classifiers = [
|
|
4
|
+
"Intended Audience :: Developers",
|
|
5
|
+
"Operating System :: OS Independent",
|
|
6
|
+
"Programming Language :: Python :: 3.10",
|
|
7
|
+
"Programming Language :: Python :: 3.11",
|
|
8
|
+
"Programming Language :: Python :: 3.12",
|
|
9
|
+
"Programming Language :: Python :: 3.13",
|
|
10
|
+
"Programming Language :: Python :: 3.14",
|
|
11
|
+
"Topic :: Software Development :: Debuggers",
|
|
12
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"dacite>=1.0.0",
|
|
16
|
+
"debugpy>=1.0.0",
|
|
17
|
+
"ipdb>=0.12.0",
|
|
18
|
+
"pudb>=2019.1",
|
|
19
|
+
"rich>=10.0.0",
|
|
20
|
+
"tomlkit>=0.7.0",
|
|
21
|
+
"typer>=0.3.0",
|
|
22
|
+
]
|
|
23
|
+
description = "🏣 debug dojo, a place for zen debugging"
|
|
24
|
+
keywords = [ "debugging", "inspection", "tools", "development" ]
|
|
25
|
+
license = 'MIT'
|
|
26
|
+
license-files = [ 'LICENSE' ]
|
|
27
|
+
name = "debug-dojo"
|
|
28
|
+
readme = "README.md"
|
|
29
|
+
requires-python = ">=3.10,<3.15"
|
|
30
|
+
version = "0.6.0"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Changelog = "https://bwrob.github.io/debug-dojo/changelog/"
|
|
34
|
+
Documentation = "https://bwrob.github.io/debug-dojo/"
|
|
35
|
+
Homepage = "https://bwrob.github.io/debug-dojo/"
|
|
36
|
+
Source = "https://github.com/bwrob/debug-dojo/"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
"dojo" = "debug_dojo._cli:main"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
|
|
44
|
+
dev = [
|
|
45
|
+
"basedpyright>=1.31.2",
|
|
46
|
+
"coverage>=7.10.4",
|
|
47
|
+
"diff-cover>=9.6.0",
|
|
48
|
+
"poethepoet>=0.37.0",
|
|
49
|
+
"pytest>=8.4.1",
|
|
50
|
+
"pytest-cov>=6.2.1",
|
|
51
|
+
"ruff>=0.12.9",
|
|
52
|
+
"tach>=0.29.0",
|
|
53
|
+
]
|
|
54
|
+
docs = [
|
|
55
|
+
"mkdocs>=1.6.1",
|
|
56
|
+
"mkdocs-git-authors-plugin>=0.10.0",
|
|
57
|
+
"mkdocs-git-committers-plugin-2>=2.5.0",
|
|
58
|
+
"mkdocs-git-revision-date-localized-plugin>=1.4.7",
|
|
59
|
+
"mkdocs-material>=9.6.17",
|
|
60
|
+
"mkdocs-typer2>=0.1.5",
|
|
61
|
+
"mkdocstrings-python>=1.17.0",
|
|
62
|
+
"pymdown-extensions>=10.16.1",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
[tool.uv]
|
|
67
|
+
package = true
|
|
68
|
+
required-version = ">=0.8.0"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
[tool.basedpyright]
|
|
72
|
+
ignore = [ "examples", "tests/assets" ]
|
|
73
|
+
pythonVersion = "3.10"
|
|
74
|
+
strict = [ "src/debug_dojo/*" ]
|
|
75
|
+
typeCheckingMode = "all"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
[tool.ruff]
|
|
79
|
+
line-length = 88
|
|
80
|
+
target-version = "py310"
|
|
81
|
+
|
|
82
|
+
[tool.ruff.lint]
|
|
83
|
+
exclude = [ "examples" ]
|
|
84
|
+
ignore = [ "COM", "D203", "D211", "D213" ]
|
|
85
|
+
select = [ "ALL" ]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint.per-file-ignores]
|
|
88
|
+
"examples/*" = [ "INP001" ]
|
|
89
|
+
"examples/test_target.py" = [ "F821" ]
|
|
90
|
+
"src/debug_dojo/_installers.py" = [ "PLC0415", "T100" ]
|
|
91
|
+
"tests/*" = [ "S101", "T201" ]
|
|
92
|
+
"tests/assets/*" = [ "T201", "INP001", "F821" ]
|
|
93
|
+
|
|
94
|
+
[tool.ruff.format]
|
|
95
|
+
docstring-code-format = true
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
[tool.poe.tasks]
|
|
99
|
+
|
|
100
|
+
coverage = { cmd = "pytest --doctest-modules --verbose --cov --cov-report=xml", help = "Create test coverage report." }
|
|
101
|
+
dependencies = { cmd = "tach check", help = "Check dependency layers using tach." }
|
|
102
|
+
dependency-graph = { cmd = "tach show --mermaid -o docs/dependency_graph.mmd", help = "Generate the dependency graph." }
|
|
103
|
+
docs = { cmd = "hap run mkdocs serve", help = "Spawn docs server." }
|
|
104
|
+
format = { cmd = "ruff format --diff --config=pyproject.toml", help = "Check code formatting using ruff." }
|
|
105
|
+
lint = { cmd = "uv run ruff check --config=pyproject.toml", help = "Check code rules using ruff." }
|
|
106
|
+
precommit = { cmd = "pre-commit run --all-files", help = "Run all code quality checks." }
|
|
107
|
+
publish-docs = { cmd = "mkdocs gh-deploy --force", help = "Publish the docs to GitHub Pages." }
|
|
108
|
+
test = { cmd = "pytest", help = "Run tests using pytest." }
|
|
109
|
+
type-check = { cmd = "basedpyright src tests", help = "Check static typing using basedpyright." }
|
|
110
|
+
|
|
111
|
+
[tool.poe.tasks.code-quality]
|
|
112
|
+
help = "Run all code quality checks."
|
|
113
|
+
ignore_fail = "return_non_zero"
|
|
114
|
+
sequence = [ "fix", "precommit", "format", "lint", "type-check" ]
|
|
115
|
+
|
|
116
|
+
[tool.poe.tasks.fix]
|
|
117
|
+
default_item_type = "cmd"
|
|
118
|
+
help = "Code quality fixes using ruff."
|
|
119
|
+
ignore_fail = "return_non_zero"
|
|
120
|
+
sequence = [
|
|
121
|
+
"ruff check --fix --unsafe-fixes --config=pyproject.toml",
|
|
122
|
+
"ruff format --config=pyproject.toml",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[tool.poe.tasks.publish]
|
|
126
|
+
sequence = [
|
|
127
|
+
"code-quality",
|
|
128
|
+
{ cmd = "rm -rf dist" },
|
|
129
|
+
{ cmd = "uv build" },
|
|
130
|
+
{ cmd = "uv publish" },
|
|
131
|
+
"publish-docs",
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
[tool.docformatter]
|
|
135
|
+
black = true
|
|
136
|
+
non-cap = [ "dojo" ]
|
|
137
|
+
|
|
138
|
+
[tool.pytest.ini_options]
|
|
139
|
+
addopts = "--verbose --doctest-modules"
|
|
140
|
+
collect_imported_tests = false
|
|
141
|
+
console_output_style = "classic"
|
|
142
|
+
minversion = "8.0"
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""Command-line interface for running Python scripts or modules with debugging tools."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import runpy
|
|
6
|
+
import sys
|
|
7
|
+
import traceback
|
|
8
|
+
from bdb import BdbQuit
|
|
9
|
+
from enum import Enum
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from shutil import which
|
|
12
|
+
from typing import Annotated
|
|
13
|
+
|
|
14
|
+
import typer
|
|
15
|
+
from rich import print as rich_print
|
|
16
|
+
|
|
17
|
+
from ._config import load_config
|
|
18
|
+
from ._config_models import DebugDojoConfig, DebuggerType # noqa: TC001
|
|
19
|
+
from ._installers import install_by_config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExecMode(Enum):
|
|
23
|
+
"""Execution mode for the target."""
|
|
24
|
+
|
|
25
|
+
FILE = "file"
|
|
26
|
+
MODULE = "module"
|
|
27
|
+
EXECUTABLE = "executable"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
cli = typer.Typer(
|
|
31
|
+
name="debug_dojo",
|
|
32
|
+
help="Run a Python script or module with debugging tools installed.",
|
|
33
|
+
no_args_is_help=True,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def __execute_with_debug( # noqa: C901
|
|
38
|
+
target_name: str,
|
|
39
|
+
target_args: list[str],
|
|
40
|
+
*,
|
|
41
|
+
target_mode: ExecMode,
|
|
42
|
+
verbose: bool,
|
|
43
|
+
config: DebugDojoConfig,
|
|
44
|
+
) -> None:
|
|
45
|
+
"""Execute a target script or module with installed debugging tools.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
target_name (str): The name of the script, module, or executable to run.
|
|
49
|
+
target_args (list[str]): Arguments to pass to the target.
|
|
50
|
+
target_mode (ExecMode): The execution mode (FILE, MODULE, or EXECUTABLE).
|
|
51
|
+
verbose (bool): If True, print verbose output.
|
|
52
|
+
config (DebugDojoConfig): The debug-dojo configuration.
|
|
53
|
+
|
|
54
|
+
Raises:
|
|
55
|
+
typer.Exit: If the target file is not found, or if an import error occurs,
|
|
56
|
+
or if the script exits with a non-zero code.
|
|
57
|
+
|
|
58
|
+
"""
|
|
59
|
+
sys.argv = [target_name, *target_args]
|
|
60
|
+
|
|
61
|
+
if verbose:
|
|
62
|
+
rich_print(f"[blue]Installing debugging tools for {target_name}.[/blue]")
|
|
63
|
+
rich_print(f"[blue]Arguments for target: {target_args}[/blue]")
|
|
64
|
+
|
|
65
|
+
install_by_config(config)
|
|
66
|
+
|
|
67
|
+
if target_mode is ExecMode.MODULE:
|
|
68
|
+
runner = runpy.run_module
|
|
69
|
+
else:
|
|
70
|
+
if target_mode is ExecMode.EXECUTABLE:
|
|
71
|
+
target_name = which(target_name) or target_name
|
|
72
|
+
|
|
73
|
+
if not Path(target_name).exists():
|
|
74
|
+
raise typer.Exit(1)
|
|
75
|
+
|
|
76
|
+
runner = runpy.run_path
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
_ = runner(target_name, run_name="__main__")
|
|
80
|
+
except ImportError as e:
|
|
81
|
+
rich_print(f"[red]Error importing {target_name}:[/red]\n{e}")
|
|
82
|
+
raise typer.Exit(1) from e
|
|
83
|
+
except BdbQuit:
|
|
84
|
+
rich_print("[red]Debugging session terminated by user.[/red]")
|
|
85
|
+
raise typer.Exit(0) from None
|
|
86
|
+
except KeyboardInterrupt:
|
|
87
|
+
rich_print("[red]Execution interrupted by user.[/red]")
|
|
88
|
+
raise typer.Exit(0) from None
|
|
89
|
+
except SystemExit as e:
|
|
90
|
+
if e.code:
|
|
91
|
+
rich_print(f"[red]Script exited with code {e.code}.[/red]")
|
|
92
|
+
except Exception as e:
|
|
93
|
+
rich_print(f"[red]Error while running {target_name}:[/red]\n{e}")
|
|
94
|
+
rich_print(traceback.format_exc())
|
|
95
|
+
if config.exceptions.post_mortem:
|
|
96
|
+
import ipdb # pyright: ignore[reportMissingTypeStubs] # noqa: PLC0415, T100
|
|
97
|
+
|
|
98
|
+
rich_print("[blue]Entering post-mortem debugging session...[/blue]")
|
|
99
|
+
ipdb.post_mortem(e.__traceback__) # pyright: ignore[reportUnknownMemberType]
|
|
100
|
+
raise typer.Exit(1) from e
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@cli.command(
|
|
104
|
+
help="Run a Python script or module with debugging tools installed.",
|
|
105
|
+
no_args_is_help=True,
|
|
106
|
+
context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
|
|
107
|
+
)
|
|
108
|
+
def run_debug( # noqa: PLR0913
|
|
109
|
+
ctx: typer.Context,
|
|
110
|
+
target_name: Annotated[
|
|
111
|
+
str | None, typer.Argument(help="The target script or module to debug.")
|
|
112
|
+
] = None,
|
|
113
|
+
*,
|
|
114
|
+
config_path: Annotated[
|
|
115
|
+
Path | None, typer.Option("--config", "-c", help="Show configuration")
|
|
116
|
+
] = None,
|
|
117
|
+
debugger: Annotated[
|
|
118
|
+
DebuggerType | None,
|
|
119
|
+
typer.Option("--debugger", "-d", help="Specify the debugger to use"),
|
|
120
|
+
] = None,
|
|
121
|
+
verbose: Annotated[
|
|
122
|
+
bool,
|
|
123
|
+
typer.Option("--verbose", "-v", help="Enable verbose output"),
|
|
124
|
+
] = False,
|
|
125
|
+
module: Annotated[
|
|
126
|
+
bool,
|
|
127
|
+
typer.Option("--module", "-m", help="Run a module"),
|
|
128
|
+
] = False,
|
|
129
|
+
executable: Annotated[
|
|
130
|
+
bool,
|
|
131
|
+
typer.Option("--exec", "-e", help="Run a command"),
|
|
132
|
+
] = False,
|
|
133
|
+
) -> None:
|
|
134
|
+
"""Run a Python script, module, or executable with debug-dojo tools.
|
|
135
|
+
|
|
136
|
+
This command acts as the main entry point for `debug-dojo`, allowing users to
|
|
137
|
+
execute their code while automatically installing and configuring debugging tools
|
|
138
|
+
based on the provided options or configuration file.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
ctx (typer.Context): The Typer context object.
|
|
142
|
+
target_name (str | None): The path to the script, name of the module, or
|
|
143
|
+
name of the executable to run. If not provided,
|
|
144
|
+
the command will exit.
|
|
145
|
+
config_path (Path | None): Path to a custom configuration file
|
|
146
|
+
(e.g., `dojo.toml`).
|
|
147
|
+
debugger (DebuggerType | None): Override the default debugger specified
|
|
148
|
+
in the config.
|
|
149
|
+
verbose (bool): Enable verbose output, showing loaded configuration
|
|
150
|
+
and installation steps.
|
|
151
|
+
module (bool): Treat `target_name` as a Python module to run
|
|
152
|
+
(e.g., `dojo -m my_package.my_module`).
|
|
153
|
+
executable (bool): Treat `target_name` as an executable command to run
|
|
154
|
+
(e.g., `dojo -e pytest`).
|
|
155
|
+
|
|
156
|
+
Raises:
|
|
157
|
+
typer.Exit: If `--module` and `--exec` are used together, or if the target
|
|
158
|
+
cannot be executed, or if an error occurs during execution.
|
|
159
|
+
|
|
160
|
+
"""
|
|
161
|
+
if module and executable:
|
|
162
|
+
rich_print(
|
|
163
|
+
"[red]Error: --module and --command options are mutually exclusive.[/red]"
|
|
164
|
+
)
|
|
165
|
+
raise typer.Exit(1)
|
|
166
|
+
|
|
167
|
+
mode = (
|
|
168
|
+
ExecMode.EXECUTABLE
|
|
169
|
+
if executable
|
|
170
|
+
else ExecMode.MODULE
|
|
171
|
+
if module
|
|
172
|
+
else ExecMode.FILE
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
config = load_config(config_path, verbose=verbose, debugger=debugger)
|
|
176
|
+
|
|
177
|
+
if verbose:
|
|
178
|
+
rich_print(f"[blue]Using debug-dojo configuration: {config} [/blue]")
|
|
179
|
+
|
|
180
|
+
if target_name:
|
|
181
|
+
__execute_with_debug(
|
|
182
|
+
target_name=target_name,
|
|
183
|
+
target_mode=mode,
|
|
184
|
+
target_args=ctx.args,
|
|
185
|
+
verbose=verbose,
|
|
186
|
+
config=config,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def main() -> None:
|
|
191
|
+
"""Run the command-line interface."""
|
|
192
|
+
cli()
|