pretty-mod 0.1.1__tar.gz → 0.2.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.
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/.gitignore +4 -1
- pretty_mod-0.2.0/CLAUDE.md +31 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/Cargo.lock +1 -1
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/Cargo.toml +1 -1
- pretty_mod-0.2.0/PKG-INFO +250 -0
- pretty_mod-0.2.0/README.md +240 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/RELEASE_NOTES.md +91 -0
- pretty_mod-0.2.0/examples/0_hello.py +29 -0
- pretty_mod-0.2.0/examples/1_tree.py +61 -0
- pretty_mod-0.2.0/examples/2_sig.py +73 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/pyproject.toml +1 -1
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/python/pretty_mod/_pretty_mod.pyi +1 -1
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/python/pretty_mod/cli.py +6 -1
- pretty_mod-0.2.0/src/config.rs +219 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/src/explorer.rs +8 -2
- pretty_mod-0.2.0/src/lib.rs +132 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/src/module_info.rs +80 -20
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/src/package_downloader.rs +31 -7
- pretty_mod-0.2.0/src/signature.rs +369 -0
- pretty_mod-0.2.0/src/stdlib.rs +35 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/src/tree_formatter.rs +63 -19
- pretty_mod-0.2.0/src/utils.rs +189 -0
- pretty_mod-0.2.0/tests/conftest.py +7 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/tests/test_cli.py +36 -36
- pretty_mod-0.2.0/tests/test_double_colon.py +19 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/tests/test_explorer.py +7 -8
- pretty_mod-0.1.1/PKG-INFO +0 -173
- pretty_mod-0.1.1/README.md +0 -163
- pretty_mod-0.1.1/examples/README.md +0 -44
- pretty_mod-0.1.1/examples/advanced_exploration.py +0 -199
- pretty_mod-0.1.1/examples/basic_usage.py +0 -87
- pretty_mod-0.1.1/src/lib.rs +0 -175
- pretty_mod-0.1.1/src/signature.rs +0 -150
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/.github/workflows/CI.yml +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/.github/workflows/tests.yml +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/.pre-commit-config.yaml +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/LICENSE +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/justfile +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/python/pretty_mod/__init__.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/python/pretty_mod/explorer.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/python/pretty_mod/py.typed +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/scripts/compare_local.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/scripts/compare_versions.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/scripts/perf_test.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/scripts/profile.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/tests/__init__.py +0 -0
- {pretty_mod-0.1.1 → pretty_mod-0.2.0}/uv.lock +0 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# overview
|
2
|
+
|
3
|
+
`pretty-mod` is a python package built on pyo3 to explore python packages for LLMs
|
4
|
+
|
5
|
+
# Getting oriented
|
6
|
+
|
7
|
+
- read @RELEASE_NOTES.md, @README.md, @pyproject.toml, and @justfile
|
8
|
+
|
9
|
+
# run the tests
|
10
|
+
|
11
|
+
```
|
12
|
+
just test
|
13
|
+
```
|
14
|
+
|
15
|
+
if for some reason you need to only build (just test does this automatically)
|
16
|
+
|
17
|
+
```
|
18
|
+
just build
|
19
|
+
```
|
20
|
+
|
21
|
+
# run the local python package
|
22
|
+
|
23
|
+
```
|
24
|
+
uv run pretty-mod tree fastapi.routing
|
25
|
+
```
|
26
|
+
|
27
|
+
# run the remote python package
|
28
|
+
|
29
|
+
```
|
30
|
+
uvx pretty-mod tree fastapi.routing
|
31
|
+
```
|
@@ -0,0 +1,250 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pretty-mod
|
3
|
+
Version: 0.2.0
|
4
|
+
License-File: LICENSE
|
5
|
+
Summary: A python module tree explorer for LLMs (and humans)
|
6
|
+
Author-email: zzstoatzz <thrast36@gmail.com>
|
7
|
+
License: MIT
|
8
|
+
Requires-Python: >=3.9
|
9
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
10
|
+
|
11
|
+
# pretty-mod
|
12
|
+
|
13
|
+
a python module tree explorer for LLMs (and humans)
|
14
|
+
|
15
|
+
> [!IMPORTANT]
|
16
|
+
> for all versions `>=0.1.0`, wheels for different operating systems are built via `maturin` and published to pypi, install `<0.1.0` for a pure python version
|
17
|
+
|
18
|
+
> [!NOTE]
|
19
|
+
> Starting from v0.2.0, output includes colors by default. Use `PRETTY_MOD_NO_COLOR=1` to disable.
|
20
|
+
|
21
|
+
```bash
|
22
|
+
# Explore module structure
|
23
|
+
» uvx pretty-mod tree json
|
24
|
+
📦 json
|
25
|
+
├── 📜 __all__: dump, dumps, load, loads, JSONDecoder, JSONDecodeError, JSONEncoder
|
26
|
+
├── ⚡ functions: dump, dumps, load, loads
|
27
|
+
├── 📦 decoder
|
28
|
+
│ ├── 📜 __all__: JSONDecoder, JSONDecodeError
|
29
|
+
│ └── 🔷 classes: JSONDecodeError, JSONDecoder
|
30
|
+
├── 📦 encoder
|
31
|
+
│ ├── 🔷 classes: JSONEncoder
|
32
|
+
│ └── ⚡ functions: py_encode_basestring, py_encode_basestring_ascii
|
33
|
+
├── 📦 scanner
|
34
|
+
│ └── 📜 __all__: make_scanner
|
35
|
+
└── 📦 tool
|
36
|
+
└── ⚡ functions: main
|
37
|
+
|
38
|
+
# Inspect function signatures (even if the package is not installed)
|
39
|
+
» uv run pretty-mod sig fastmcp:FastMCP --quiet
|
40
|
+
📎 FastMCP
|
41
|
+
├── Parameters:
|
42
|
+
├── self
|
43
|
+
├── name: str | None=None
|
44
|
+
├── instructions: str | None=None
|
45
|
+
├── auth: OAuthProvider | None=None
|
46
|
+
├── lifespan: Callable[[FastMCP[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None=None
|
47
|
+
├── tool_serializer: Callable[[Any], str] | None=None
|
48
|
+
├── cache_expiration_seconds: float | None=None
|
49
|
+
├── on_duplicate_tools: DuplicateBehavior | None=None
|
50
|
+
├── on_duplicate_resources: DuplicateBehavior | None=None
|
51
|
+
├── on_duplicate_prompts: DuplicateBehavior | None=None
|
52
|
+
├── resource_prefix_format: Literal['protocol', 'path'] | None=None
|
53
|
+
├── mask_error_details: bool | None=None
|
54
|
+
├── tools: list[Tool | Callable[..., Any]] | None=None
|
55
|
+
├── dependencies: list[str] | None=None
|
56
|
+
├── include_tags: set[str] | None=None
|
57
|
+
├── exclude_tags: set[str] | None=None
|
58
|
+
├── log_level: str | None=None
|
59
|
+
├── debug: bool | None=None
|
60
|
+
├── host: str | None=None
|
61
|
+
├── port: int | None=None
|
62
|
+
├── sse_path: str | None=None
|
63
|
+
├── message_path: str | None=None
|
64
|
+
├── streamable_http_path: str | None=None
|
65
|
+
├── json_response: bool | None=None
|
66
|
+
└── stateless_http: bool | None=None
|
67
|
+
```
|
68
|
+
|
69
|
+
## installation
|
70
|
+
|
71
|
+
```bash
|
72
|
+
uv add pretty-mod
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
## cli
|
77
|
+
|
78
|
+
`pretty-mod` includes a command-line interface for shell-based exploration:
|
79
|
+
|
80
|
+
> [!IMPORTANT]
|
81
|
+
> all commands below can be run ephemerally with `uvx`, e.g. `uvx pretty-mod tree json`
|
82
|
+
|
83
|
+
```bash
|
84
|
+
# Explore module structure
|
85
|
+
pretty-mod tree json
|
86
|
+
|
87
|
+
# Go deeper into the tree with --depth
|
88
|
+
pretty-mod tree requests --depth 3
|
89
|
+
|
90
|
+
# Display function signatures
|
91
|
+
pretty-mod sig json:loads
|
92
|
+
pretty-mod sig os.path:join
|
93
|
+
|
94
|
+
# Explore packages even without having them installed
|
95
|
+
pretty-mod tree django
|
96
|
+
pretty-mod tree flask --depth 1
|
97
|
+
|
98
|
+
# Use --quiet to suppress download messages
|
99
|
+
pretty-mod tree requests --quiet
|
100
|
+
|
101
|
+
# Version specifiers - explore specific versions
|
102
|
+
pretty-mod tree toml@0.10.2
|
103
|
+
pretty-mod sig toml@0.10.2:loads
|
104
|
+
|
105
|
+
# Submodules with version specifiers (correct syntax)
|
106
|
+
pretty-mod tree prefect.server@2.10.0 # ✅ Works
|
107
|
+
pretty-mod tree prefect@2.10.0.server # ❌ Invalid - version must come last
|
108
|
+
|
109
|
+
# Package name differs from module name
|
110
|
+
pretty-mod tree pydocket::docket # PyPI package 'pydocket' contains module 'docket'
|
111
|
+
pretty-mod tree pillow::PIL # PyPI package 'pillow' contains module 'PIL'
|
112
|
+
pretty-mod tree pillow::PIL@10.0.0 # Specific version of pillow
|
113
|
+
pretty-mod sig pillow::PIL.Image:open # Works with signatures too
|
114
|
+
```
|
115
|
+
|
116
|
+
## python sdk
|
117
|
+
|
118
|
+
```python
|
119
|
+
from pretty_mod import display_tree
|
120
|
+
|
121
|
+
# Explore a module structure
|
122
|
+
display_tree("collections", max_depth=2)
|
123
|
+
```
|
124
|
+
|
125
|
+
<details>
|
126
|
+
<summary>Example output</summary>
|
127
|
+
|
128
|
+
```text
|
129
|
+
display_tree("collections", max_depth=2)
|
130
|
+
|
131
|
+
📦 collections
|
132
|
+
├── 📜 __all__: ChainMap, Counter, OrderedDict, UserDict, UserList, UserString, defaultdict, deque, namedtuple
|
133
|
+
├── 🔷 classes: ChainMap, Counter, OrderedDict, UserDict, UserList, UserString, defaultdict, deque
|
134
|
+
├── ⚡ functions: namedtuple
|
135
|
+
└── 📦 abc
|
136
|
+
├── 📜 __all__: Awaitable, Coroutine, AsyncIterable, AsyncIterator, AsyncGenerator, Hashable, Iterable, Iterator, Generator, Reversible, Sized, Container, Callable, Collection, Set, MutableSet, Mapping, MutableMapping, MappingView, KeysView, ItemsView, ValuesView, Sequence, MutableSequence, ByteString, Buffer
|
137
|
+
└── 🔷 classes: AsyncGenerator, AsyncIterable, AsyncIterator, Awaitable, Buffer, ByteString, Callable, Collection, Container, Coroutine, Generator, Hashable, ItemsView, Iterable, Iterator, KeysView, Mapping, MappingView, MutableMapping, MutableSequence, MutableSet, Reversible, Sequence, Set, Sized, ValuesView
|
138
|
+
```
|
139
|
+
</details>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```python
|
144
|
+
from pretty_mod import display_signature
|
145
|
+
|
146
|
+
# Display the signature of a callable (function, class constructor, etc.)
|
147
|
+
print(display_signature("json:loads"))
|
148
|
+
```
|
149
|
+
|
150
|
+
<details>
|
151
|
+
<summary>Example output</summary>
|
152
|
+
|
153
|
+
```text
|
154
|
+
📎 loads
|
155
|
+
├── Parameters:
|
156
|
+
├── s
|
157
|
+
├── *
|
158
|
+
├── cls=None
|
159
|
+
├── object_hook=None
|
160
|
+
├── parse_float=None
|
161
|
+
├── parse_int=None
|
162
|
+
├── parse_constant=None
|
163
|
+
├── object_pairs_hook=None
|
164
|
+
└── **kw
|
165
|
+
```
|
166
|
+
</details>
|
167
|
+
|
168
|
+
## customization
|
169
|
+
|
170
|
+
pretty-mod supports extensive customization through environment variables:
|
171
|
+
|
172
|
+
### display characters
|
173
|
+
|
174
|
+
```bash
|
175
|
+
# Use ASCII-only mode for terminals without Unicode support
|
176
|
+
PRETTY_MOD_ASCII=1 pretty-mod tree json
|
177
|
+
|
178
|
+
# Customize individual icons
|
179
|
+
PRETTY_MOD_MODULE_ICON="[M]" pretty-mod tree json
|
180
|
+
PRETTY_MOD_FUNCTION_ICON="fn" pretty-mod tree json
|
181
|
+
PRETTY_MOD_CLASS_ICON="cls" pretty-mod tree json
|
182
|
+
```
|
183
|
+
|
184
|
+
### colors
|
185
|
+
|
186
|
+
pretty-mod uses an earth-tone color scheme by default:
|
187
|
+
|
188
|
+
```bash
|
189
|
+
# Disable colors entirely
|
190
|
+
PRETTY_MOD_NO_COLOR=1 pretty-mod tree json
|
191
|
+
# or use the standard NO_COLOR environment variable
|
192
|
+
NO_COLOR=1 pretty-mod tree json
|
193
|
+
|
194
|
+
# Override specific colors with hex values
|
195
|
+
PRETTY_MOD_MODULE_COLOR="#FF6B6B" pretty-mod tree json
|
196
|
+
PRETTY_MOD_FUNCTION_COLOR="#4ECDC4" pretty-mod tree json
|
197
|
+
```
|
198
|
+
|
199
|
+
available color environment variables:
|
200
|
+
- `PRETTY_MOD_MODULE_COLOR` - Modules/packages (default: #8B7355)
|
201
|
+
- `PRETTY_MOD_FUNCTION_COLOR` - Functions (default: #6B8E23)
|
202
|
+
- `PRETTY_MOD_CLASS_COLOR` - Classes (default: #4682B4)
|
203
|
+
- `PRETTY_MOD_CONSTANT_COLOR` - Constants (default: #BC8F8F)
|
204
|
+
- `PRETTY_MOD_EXPORTS_COLOR` - __all__ exports (default: #9370DB)
|
205
|
+
- `PRETTY_MOD_SIGNATURE_COLOR` - Signatures (default: #5F9EA0)
|
206
|
+
- `PRETTY_MOD_TREE_COLOR` - Tree structure lines (default: #696969)
|
207
|
+
- `PRETTY_MOD_PARAM_COLOR` - Parameter names (default: #708090)
|
208
|
+
- `PRETTY_MOD_TYPE_COLOR` - Type annotations (default: #778899)
|
209
|
+
- `PRETTY_MOD_DEFAULT_COLOR` - Default values (default: #8FBC8F)
|
210
|
+
- `PRETTY_MOD_WARNING_COLOR` - Warning messages (default: #DAA520)
|
211
|
+
|
212
|
+
## examples
|
213
|
+
|
214
|
+
see the [`examples/`](examples/) directory for more detailed usage patterns and advanced features.
|
215
|
+
|
216
|
+
## development
|
217
|
+
|
218
|
+
```bash
|
219
|
+
gh repo clone zzstoatzz/pretty-mod && cd pretty-mod
|
220
|
+
just --list # see https://github.com/casey/just
|
221
|
+
```
|
222
|
+
|
223
|
+
<details>
|
224
|
+
<summary>Performance Testing</summary>
|
225
|
+
|
226
|
+
The performance test script (`scripts/perf_test.py`) supports both single-run exploration and proper benchmarking with multiple iterations:
|
227
|
+
|
228
|
+
```bash
|
229
|
+
# Run a proper benchmark with multiple iterations
|
230
|
+
./scripts/perf_test.py json --benchmark
|
231
|
+
./scripts/perf_test.py urllib --benchmark --runs 100 --warmup 10
|
232
|
+
|
233
|
+
# Compare performance between local and published versions
|
234
|
+
just compare-perf prefect 2
|
235
|
+
|
236
|
+
# Benchmark multiple modules
|
237
|
+
just benchmark-modules
|
238
|
+
|
239
|
+
# Or use shell timing for quick single-run comparisons
|
240
|
+
time ./scripts/perf_test.py numpy --depth 3
|
241
|
+
time uvx pretty-mod tree numpy --depth 3
|
242
|
+
```
|
243
|
+
|
244
|
+
Benchmark mode provides:
|
245
|
+
- Warmup runs to account for cold starts
|
246
|
+
- Multiple iterations for statistical significance
|
247
|
+
- Mean, standard deviation, min/max timing statistics
|
248
|
+
- Silent operation (no tree output) for accurate timing
|
249
|
+
|
250
|
+
</details>
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# pretty-mod
|
2
|
+
|
3
|
+
a python module tree explorer for LLMs (and humans)
|
4
|
+
|
5
|
+
> [!IMPORTANT]
|
6
|
+
> for all versions `>=0.1.0`, wheels for different operating systems are built via `maturin` and published to pypi, install `<0.1.0` for a pure python version
|
7
|
+
|
8
|
+
> [!NOTE]
|
9
|
+
> Starting from v0.2.0, output includes colors by default. Use `PRETTY_MOD_NO_COLOR=1` to disable.
|
10
|
+
|
11
|
+
```bash
|
12
|
+
# Explore module structure
|
13
|
+
» uvx pretty-mod tree json
|
14
|
+
📦 json
|
15
|
+
├── 📜 __all__: dump, dumps, load, loads, JSONDecoder, JSONDecodeError, JSONEncoder
|
16
|
+
├── ⚡ functions: dump, dumps, load, loads
|
17
|
+
├── 📦 decoder
|
18
|
+
│ ├── 📜 __all__: JSONDecoder, JSONDecodeError
|
19
|
+
│ └── 🔷 classes: JSONDecodeError, JSONDecoder
|
20
|
+
├── 📦 encoder
|
21
|
+
│ ├── 🔷 classes: JSONEncoder
|
22
|
+
│ └── ⚡ functions: py_encode_basestring, py_encode_basestring_ascii
|
23
|
+
├── 📦 scanner
|
24
|
+
│ └── 📜 __all__: make_scanner
|
25
|
+
└── 📦 tool
|
26
|
+
└── ⚡ functions: main
|
27
|
+
|
28
|
+
# Inspect function signatures (even if the package is not installed)
|
29
|
+
» uv run pretty-mod sig fastmcp:FastMCP --quiet
|
30
|
+
📎 FastMCP
|
31
|
+
├── Parameters:
|
32
|
+
├── self
|
33
|
+
├── name: str | None=None
|
34
|
+
├── instructions: str | None=None
|
35
|
+
├── auth: OAuthProvider | None=None
|
36
|
+
├── lifespan: Callable[[FastMCP[LifespanResultT]], AbstractAsyncContextManager[LifespanResultT]] | None=None
|
37
|
+
├── tool_serializer: Callable[[Any], str] | None=None
|
38
|
+
├── cache_expiration_seconds: float | None=None
|
39
|
+
├── on_duplicate_tools: DuplicateBehavior | None=None
|
40
|
+
├── on_duplicate_resources: DuplicateBehavior | None=None
|
41
|
+
├── on_duplicate_prompts: DuplicateBehavior | None=None
|
42
|
+
├── resource_prefix_format: Literal['protocol', 'path'] | None=None
|
43
|
+
├── mask_error_details: bool | None=None
|
44
|
+
├── tools: list[Tool | Callable[..., Any]] | None=None
|
45
|
+
├── dependencies: list[str] | None=None
|
46
|
+
├── include_tags: set[str] | None=None
|
47
|
+
├── exclude_tags: set[str] | None=None
|
48
|
+
├── log_level: str | None=None
|
49
|
+
├── debug: bool | None=None
|
50
|
+
├── host: str | None=None
|
51
|
+
├── port: int | None=None
|
52
|
+
├── sse_path: str | None=None
|
53
|
+
├── message_path: str | None=None
|
54
|
+
├── streamable_http_path: str | None=None
|
55
|
+
├── json_response: bool | None=None
|
56
|
+
└── stateless_http: bool | None=None
|
57
|
+
```
|
58
|
+
|
59
|
+
## installation
|
60
|
+
|
61
|
+
```bash
|
62
|
+
uv add pretty-mod
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
## cli
|
67
|
+
|
68
|
+
`pretty-mod` includes a command-line interface for shell-based exploration:
|
69
|
+
|
70
|
+
> [!IMPORTANT]
|
71
|
+
> all commands below can be run ephemerally with `uvx`, e.g. `uvx pretty-mod tree json`
|
72
|
+
|
73
|
+
```bash
|
74
|
+
# Explore module structure
|
75
|
+
pretty-mod tree json
|
76
|
+
|
77
|
+
# Go deeper into the tree with --depth
|
78
|
+
pretty-mod tree requests --depth 3
|
79
|
+
|
80
|
+
# Display function signatures
|
81
|
+
pretty-mod sig json:loads
|
82
|
+
pretty-mod sig os.path:join
|
83
|
+
|
84
|
+
# Explore packages even without having them installed
|
85
|
+
pretty-mod tree django
|
86
|
+
pretty-mod tree flask --depth 1
|
87
|
+
|
88
|
+
# Use --quiet to suppress download messages
|
89
|
+
pretty-mod tree requests --quiet
|
90
|
+
|
91
|
+
# Version specifiers - explore specific versions
|
92
|
+
pretty-mod tree toml@0.10.2
|
93
|
+
pretty-mod sig toml@0.10.2:loads
|
94
|
+
|
95
|
+
# Submodules with version specifiers (correct syntax)
|
96
|
+
pretty-mod tree prefect.server@2.10.0 # ✅ Works
|
97
|
+
pretty-mod tree prefect@2.10.0.server # ❌ Invalid - version must come last
|
98
|
+
|
99
|
+
# Package name differs from module name
|
100
|
+
pretty-mod tree pydocket::docket # PyPI package 'pydocket' contains module 'docket'
|
101
|
+
pretty-mod tree pillow::PIL # PyPI package 'pillow' contains module 'PIL'
|
102
|
+
pretty-mod tree pillow::PIL@10.0.0 # Specific version of pillow
|
103
|
+
pretty-mod sig pillow::PIL.Image:open # Works with signatures too
|
104
|
+
```
|
105
|
+
|
106
|
+
## python sdk
|
107
|
+
|
108
|
+
```python
|
109
|
+
from pretty_mod import display_tree
|
110
|
+
|
111
|
+
# Explore a module structure
|
112
|
+
display_tree("collections", max_depth=2)
|
113
|
+
```
|
114
|
+
|
115
|
+
<details>
|
116
|
+
<summary>Example output</summary>
|
117
|
+
|
118
|
+
```text
|
119
|
+
display_tree("collections", max_depth=2)
|
120
|
+
|
121
|
+
📦 collections
|
122
|
+
├── 📜 __all__: ChainMap, Counter, OrderedDict, UserDict, UserList, UserString, defaultdict, deque, namedtuple
|
123
|
+
├── 🔷 classes: ChainMap, Counter, OrderedDict, UserDict, UserList, UserString, defaultdict, deque
|
124
|
+
├── ⚡ functions: namedtuple
|
125
|
+
└── 📦 abc
|
126
|
+
├── 📜 __all__: Awaitable, Coroutine, AsyncIterable, AsyncIterator, AsyncGenerator, Hashable, Iterable, Iterator, Generator, Reversible, Sized, Container, Callable, Collection, Set, MutableSet, Mapping, MutableMapping, MappingView, KeysView, ItemsView, ValuesView, Sequence, MutableSequence, ByteString, Buffer
|
127
|
+
└── 🔷 classes: AsyncGenerator, AsyncIterable, AsyncIterator, Awaitable, Buffer, ByteString, Callable, Collection, Container, Coroutine, Generator, Hashable, ItemsView, Iterable, Iterator, KeysView, Mapping, MappingView, MutableMapping, MutableSequence, MutableSet, Reversible, Sequence, Set, Sized, ValuesView
|
128
|
+
```
|
129
|
+
</details>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
```python
|
134
|
+
from pretty_mod import display_signature
|
135
|
+
|
136
|
+
# Display the signature of a callable (function, class constructor, etc.)
|
137
|
+
print(display_signature("json:loads"))
|
138
|
+
```
|
139
|
+
|
140
|
+
<details>
|
141
|
+
<summary>Example output</summary>
|
142
|
+
|
143
|
+
```text
|
144
|
+
📎 loads
|
145
|
+
├── Parameters:
|
146
|
+
├── s
|
147
|
+
├── *
|
148
|
+
├── cls=None
|
149
|
+
├── object_hook=None
|
150
|
+
├── parse_float=None
|
151
|
+
├── parse_int=None
|
152
|
+
├── parse_constant=None
|
153
|
+
├── object_pairs_hook=None
|
154
|
+
└── **kw
|
155
|
+
```
|
156
|
+
</details>
|
157
|
+
|
158
|
+
## customization
|
159
|
+
|
160
|
+
pretty-mod supports extensive customization through environment variables:
|
161
|
+
|
162
|
+
### display characters
|
163
|
+
|
164
|
+
```bash
|
165
|
+
# Use ASCII-only mode for terminals without Unicode support
|
166
|
+
PRETTY_MOD_ASCII=1 pretty-mod tree json
|
167
|
+
|
168
|
+
# Customize individual icons
|
169
|
+
PRETTY_MOD_MODULE_ICON="[M]" pretty-mod tree json
|
170
|
+
PRETTY_MOD_FUNCTION_ICON="fn" pretty-mod tree json
|
171
|
+
PRETTY_MOD_CLASS_ICON="cls" pretty-mod tree json
|
172
|
+
```
|
173
|
+
|
174
|
+
### colors
|
175
|
+
|
176
|
+
pretty-mod uses an earth-tone color scheme by default:
|
177
|
+
|
178
|
+
```bash
|
179
|
+
# Disable colors entirely
|
180
|
+
PRETTY_MOD_NO_COLOR=1 pretty-mod tree json
|
181
|
+
# or use the standard NO_COLOR environment variable
|
182
|
+
NO_COLOR=1 pretty-mod tree json
|
183
|
+
|
184
|
+
# Override specific colors with hex values
|
185
|
+
PRETTY_MOD_MODULE_COLOR="#FF6B6B" pretty-mod tree json
|
186
|
+
PRETTY_MOD_FUNCTION_COLOR="#4ECDC4" pretty-mod tree json
|
187
|
+
```
|
188
|
+
|
189
|
+
available color environment variables:
|
190
|
+
- `PRETTY_MOD_MODULE_COLOR` - Modules/packages (default: #8B7355)
|
191
|
+
- `PRETTY_MOD_FUNCTION_COLOR` - Functions (default: #6B8E23)
|
192
|
+
- `PRETTY_MOD_CLASS_COLOR` - Classes (default: #4682B4)
|
193
|
+
- `PRETTY_MOD_CONSTANT_COLOR` - Constants (default: #BC8F8F)
|
194
|
+
- `PRETTY_MOD_EXPORTS_COLOR` - __all__ exports (default: #9370DB)
|
195
|
+
- `PRETTY_MOD_SIGNATURE_COLOR` - Signatures (default: #5F9EA0)
|
196
|
+
- `PRETTY_MOD_TREE_COLOR` - Tree structure lines (default: #696969)
|
197
|
+
- `PRETTY_MOD_PARAM_COLOR` - Parameter names (default: #708090)
|
198
|
+
- `PRETTY_MOD_TYPE_COLOR` - Type annotations (default: #778899)
|
199
|
+
- `PRETTY_MOD_DEFAULT_COLOR` - Default values (default: #8FBC8F)
|
200
|
+
- `PRETTY_MOD_WARNING_COLOR` - Warning messages (default: #DAA520)
|
201
|
+
|
202
|
+
## examples
|
203
|
+
|
204
|
+
see the [`examples/`](examples/) directory for more detailed usage patterns and advanced features.
|
205
|
+
|
206
|
+
## development
|
207
|
+
|
208
|
+
```bash
|
209
|
+
gh repo clone zzstoatzz/pretty-mod && cd pretty-mod
|
210
|
+
just --list # see https://github.com/casey/just
|
211
|
+
```
|
212
|
+
|
213
|
+
<details>
|
214
|
+
<summary>Performance Testing</summary>
|
215
|
+
|
216
|
+
The performance test script (`scripts/perf_test.py`) supports both single-run exploration and proper benchmarking with multiple iterations:
|
217
|
+
|
218
|
+
```bash
|
219
|
+
# Run a proper benchmark with multiple iterations
|
220
|
+
./scripts/perf_test.py json --benchmark
|
221
|
+
./scripts/perf_test.py urllib --benchmark --runs 100 --warmup 10
|
222
|
+
|
223
|
+
# Compare performance between local and published versions
|
224
|
+
just compare-perf prefect 2
|
225
|
+
|
226
|
+
# Benchmark multiple modules
|
227
|
+
just benchmark-modules
|
228
|
+
|
229
|
+
# Or use shell timing for quick single-run comparisons
|
230
|
+
time ./scripts/perf_test.py numpy --depth 3
|
231
|
+
time uvx pretty-mod tree numpy --depth 3
|
232
|
+
```
|
233
|
+
|
234
|
+
Benchmark mode provides:
|
235
|
+
- Warmup runs to account for cold starts
|
236
|
+
- Multiple iterations for statistical significance
|
237
|
+
- Mean, standard deviation, min/max timing statistics
|
238
|
+
- Silent operation (no tree output) for accurate timing
|
239
|
+
|
240
|
+
</details>
|
@@ -1,3 +1,94 @@
|
|
1
|
+
# Release Notes - v0.2.0
|
2
|
+
|
3
|
+
## 🎨 Customizable Display & Colors + Enhanced Signature Support
|
4
|
+
|
5
|
+
This release introduces customizable display characters, color output, full type annotation support in signatures, and a new double-colon syntax for handling packages where the PyPI name differs from the module name.
|
6
|
+
|
7
|
+
### 🚨 Breaking Changes
|
8
|
+
- **Color output by default**: Tree and signature displays now include ANSI color codes
|
9
|
+
- **Minor version bump**: Due to visual output changes, this is a minor version release
|
10
|
+
|
11
|
+
### ✨ New Features
|
12
|
+
|
13
|
+
- **🔗 Double-colon syntax**: Handle packages where PyPI name differs from module name
|
14
|
+
- `pretty-mod tree pydocket::docket` - Download 'pydocket' package, explore 'docket' module
|
15
|
+
- `pretty-mod tree pillow::PIL` - Download 'pillow' package, explore 'PIL' module
|
16
|
+
- Works with version specifiers: `pretty-mod tree pillow::PIL@10.0.0`
|
17
|
+
- Works with signatures: `pretty-mod sig pillow::PIL.Image:open`
|
18
|
+
|
19
|
+
- **📝 Full Type Annotation Support**: Signatures now display complete type information
|
20
|
+
- Union types: `str | None`
|
21
|
+
- Generic types: `list[Tool | Callable[..., Any]]`
|
22
|
+
- Literal types: `Literal['protocol', 'path']`
|
23
|
+
- Complex nested types properly rendered from AST
|
24
|
+
|
25
|
+
- **🎨 Color Support**: Earth-tone/pastel color scheme
|
26
|
+
- Modules: Saddle brown (#8B7355)
|
27
|
+
- Functions: Olive drab (#6B8E23)
|
28
|
+
- Classes: Steel blue (#4682B4)
|
29
|
+
- Constants: Rosy brown (#BC8F8F)
|
30
|
+
- Warning messages: Goldenrod (#DAA520)
|
31
|
+
- And more subtle colors for parameters, types, and tree structures
|
32
|
+
|
33
|
+
- **🔧 Customizable Display Characters**: Configure via environment variables
|
34
|
+
- `PRETTY_MOD_MODULE_ICON`: Icon for modules (default: 📦)
|
35
|
+
- `PRETTY_MOD_FUNCTION_ICON`: Icon for functions (default: ⚡)
|
36
|
+
- `PRETTY_MOD_CLASS_ICON`: Icon for classes (default: 🔷)
|
37
|
+
- `PRETTY_MOD_CONSTANT_ICON`: Icon for constants (default: 📌)
|
38
|
+
- `PRETTY_MOD_EXPORTS_ICON`: Icon for __all__ exports (default: 📜)
|
39
|
+
- `PRETTY_MOD_SIGNATURE_ICON`: Icon for signatures (default: 📎)
|
40
|
+
|
41
|
+
- **🖥️ ASCII Mode**: For terminals without Unicode support
|
42
|
+
```bash
|
43
|
+
PRETTY_MOD_ASCII=1 pretty-mod tree json
|
44
|
+
```
|
45
|
+
|
46
|
+
- **🚫 Disable Colors**: For clean output or piping
|
47
|
+
```bash
|
48
|
+
PRETTY_MOD_NO_COLOR=1 pretty-mod tree json
|
49
|
+
# or use the standard NO_COLOR environment variable
|
50
|
+
```
|
51
|
+
|
52
|
+
- **🎯 Custom Colors**: Override any color with hex values
|
53
|
+
```bash
|
54
|
+
PRETTY_MOD_MODULE_COLOR=#FF6B6B pretty-mod tree json
|
55
|
+
```
|
56
|
+
|
57
|
+
### 🏗️ Technical Improvements
|
58
|
+
|
59
|
+
- **Configuration system**: Centralized configuration module with environment variable support
|
60
|
+
- **Color rendering**: ANSI 24-bit true color support with automatic hex-to-RGB conversion
|
61
|
+
- **Consistent styling**: Both tree and signature displays use the same configuration system
|
62
|
+
- **Enhanced AST parsing**: Better handling of complex type annotations and expressions
|
63
|
+
- **Code organization**: Consolidated signature parsing logic for better maintainability
|
64
|
+
|
65
|
+
### 🐛 Bug Fixes
|
66
|
+
|
67
|
+
- **Stdlib module handling**: Built-in modules no longer trigger PyPI download attempts
|
68
|
+
- **Signature discovery**: Improved recursive search for symbols exported in `__all__`
|
69
|
+
- **Download messages**: Colored warning messages for better visibility
|
70
|
+
|
71
|
+
---
|
72
|
+
|
73
|
+
# Release Notes - v0.1.2
|
74
|
+
|
75
|
+
## 🔧 Code Quality Improvements
|
76
|
+
|
77
|
+
### ✨ New Features
|
78
|
+
|
79
|
+
- **Version specifiers**: Support for `@version` syntax (e.g., `pretty-mod tree toml@0.10.2`)
|
80
|
+
- Use `@latest` to force download of the latest version
|
81
|
+
- Specify exact versions like `@1.2.3`
|
82
|
+
- Works with both `tree` and `sig` commands
|
83
|
+
|
84
|
+
### 🏗️ Technical Improvements
|
85
|
+
|
86
|
+
- **Performance**: Use Rust's native `println!` instead of Python's print for better performance
|
87
|
+
- **Architecture**: Consolidated shared utilities into a dedicated `utils.rs` module
|
88
|
+
- **Code organization**: Moved all implementation details out of `lib.rs`, which now only contains PyO3 bindings
|
89
|
+
|
90
|
+
---
|
91
|
+
|
1
92
|
# Release Notes - v0.1.1
|
2
93
|
|
3
94
|
## 🎯 Auto-Download Support
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"""
|
2
|
+
Welcome to pretty-mod!
|
3
|
+
|
4
|
+
This is a Python library for exploring and understanding Python modules programmatically.
|
5
|
+
Perfect for LLMs, developers exploring unfamiliar code, or building developer tools.
|
6
|
+
|
7
|
+
Key features:
|
8
|
+
- Explore module structures without importing them (filesystem-based discovery)
|
9
|
+
- Display function signatures in a beautiful tree format
|
10
|
+
- Auto-download packages from PyPI when needed
|
11
|
+
- Support for version specifiers (e.g., requests@2.31.0)
|
12
|
+
"""
|
13
|
+
|
14
|
+
from pretty_mod import display_signature, display_tree
|
15
|
+
|
16
|
+
# Quick overview - let's explore Python's json module
|
17
|
+
print("📦 Exploring Python's json module:")
|
18
|
+
display_tree("json", max_depth=1)
|
19
|
+
|
20
|
+
print("\n📎 Looking at a function signature:")
|
21
|
+
print(display_signature("json:dumps"))
|
22
|
+
|
23
|
+
print("\n✨ Auto-download example (if requests isn't installed):")
|
24
|
+
# This will download requests from PyPI if not installed!
|
25
|
+
display_tree("requests", max_depth=1, quiet=True)
|
26
|
+
|
27
|
+
print("\n🎯 Version specifiers - explore specific versions:")
|
28
|
+
# Download and explore a specific version
|
29
|
+
display_tree("toml@0.10.2", max_depth=1, quiet=True)
|