hydrust 0.5.0__py3-none-win_amd64.whl
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.
- hydrust/__init__.py +81 -0
- hydrust/__main__.py +18 -0
- hydrust/py.typed +0 -0
- hydrust-0.5.0.data/scripts/hydrust.exe +0 -0
- hydrust-0.5.0.dist-info/METADATA +184 -0
- hydrust-0.5.0.dist-info/RECORD +9 -0
- hydrust-0.5.0.dist-info/WHEEL +4 -0
- hydrust-0.5.0.dist-info/licenses/LICENSE +21 -0
- hydrust-0.5.0.dist-info/sboms/hydrust.cyclonedx.json +9623 -0
hydrust/__init__.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Locate the `hydrust` executable installed alongside this package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import sysconfig
|
|
8
|
+
|
|
9
|
+
__all__ = ["find_hydrust_bin"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def find_hydrust_bin() -> str:
|
|
13
|
+
"""Return the path to the `hydrust` binary installed with this package."""
|
|
14
|
+
|
|
15
|
+
hydrust_exe = "hydrust" + sysconfig.get_config_var("EXE")
|
|
16
|
+
|
|
17
|
+
# The scripts directory of the environment this package is installed into.
|
|
18
|
+
scripts_path = os.path.join(sysconfig.get_path("scripts"), hydrust_exe)
|
|
19
|
+
if os.path.isfile(scripts_path):
|
|
20
|
+
return scripts_path
|
|
21
|
+
|
|
22
|
+
# A `pip install --user` install.
|
|
23
|
+
if sys.version_info >= (3, 10):
|
|
24
|
+
user_scheme = sysconfig.get_preferred_scheme("user")
|
|
25
|
+
elif os.name == "nt":
|
|
26
|
+
user_scheme = "nt_user"
|
|
27
|
+
elif sys.platform == "darwin" and getattr(sys, "_framework", ""):
|
|
28
|
+
user_scheme = "osx_framework_user"
|
|
29
|
+
else:
|
|
30
|
+
user_scheme = "posix_user"
|
|
31
|
+
|
|
32
|
+
user_path = os.path.join(
|
|
33
|
+
sysconfig.get_path("scripts", scheme=user_scheme), hydrust_exe
|
|
34
|
+
)
|
|
35
|
+
if os.path.isfile(user_path):
|
|
36
|
+
return user_path
|
|
37
|
+
|
|
38
|
+
# A `pip install --target` install, where the scripts land in `bin/` next
|
|
39
|
+
# to the package directory.
|
|
40
|
+
pkg_root = os.path.dirname(os.path.dirname(__file__))
|
|
41
|
+
target_path = os.path.join(pkg_root, "bin", hydrust_exe)
|
|
42
|
+
if os.path.isfile(target_path):
|
|
43
|
+
return target_path
|
|
44
|
+
|
|
45
|
+
# An isolated build environment created by pip, e.g. when `hydrust` is a
|
|
46
|
+
# build requirement. pip puts `<tmp>/pip-build-env-<rand>/overlay/bin` and
|
|
47
|
+
# `<tmp>/pip-build-env-<rand>/normal/bin` at the front of PATH, and the
|
|
48
|
+
# binary lives in the first. See:
|
|
49
|
+
# https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
|
|
50
|
+
paths = os.environ.get("PATH", "").split(os.pathsep)
|
|
51
|
+
if len(paths) >= 2:
|
|
52
|
+
|
|
53
|
+
def get_last_three_path_parts(path: str) -> list[str]:
|
|
54
|
+
"""Return a list of up to the last three parts of a path."""
|
|
55
|
+
parts = []
|
|
56
|
+
while len(parts) < 3:
|
|
57
|
+
head, tail = os.path.split(path)
|
|
58
|
+
if tail or head != path:
|
|
59
|
+
parts.append(tail)
|
|
60
|
+
path = head
|
|
61
|
+
else:
|
|
62
|
+
parts.append(path)
|
|
63
|
+
break
|
|
64
|
+
return parts
|
|
65
|
+
|
|
66
|
+
maybe_overlay = get_last_three_path_parts(paths[0])
|
|
67
|
+
maybe_normal = get_last_three_path_parts(paths[1])
|
|
68
|
+
if (
|
|
69
|
+
len(maybe_normal) >= 3
|
|
70
|
+
and maybe_normal[-1].startswith("pip-build-env-")
|
|
71
|
+
and maybe_normal[-2] == "normal"
|
|
72
|
+
and len(maybe_overlay) >= 3
|
|
73
|
+
and maybe_overlay[-1].startswith("pip-build-env-")
|
|
74
|
+
and maybe_overlay[-2] == "overlay"
|
|
75
|
+
):
|
|
76
|
+
# The overlay must contain the hydrust binary.
|
|
77
|
+
candidate = os.path.join(paths[0], hydrust_exe)
|
|
78
|
+
if os.path.isfile(candidate):
|
|
79
|
+
return candidate
|
|
80
|
+
|
|
81
|
+
raise FileNotFoundError(scripts_path)
|
hydrust/__main__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Run `hydrust` as `python -m hydrust`."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from hydrust import find_hydrust_bin
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
hydrust = os.fsdecode(find_hydrust_bin())
|
|
10
|
+
if sys.platform == "win32":
|
|
11
|
+
import subprocess
|
|
12
|
+
|
|
13
|
+
# `execvp` on Windows spawns a child and exits immediately, which
|
|
14
|
+
# breaks the exit code and interleaves output with the shell prompt.
|
|
15
|
+
completed_process = subprocess.run([hydrust, *sys.argv[1:]])
|
|
16
|
+
sys.exit(completed_process.returncode)
|
|
17
|
+
else:
|
|
18
|
+
os.execvp(hydrust, [hydrust, *sys.argv[1:]])
|
hydrust/py.typed
ADDED
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hydrust
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: Programming Language :: Rust
|
|
11
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Summary: Language server and CLI checker for Hydra configuration files
|
|
14
|
+
Keywords: hydra,yaml,lsp,language-server,linter
|
|
15
|
+
Author: Matthew Lyon
|
|
16
|
+
License-Expression: MIT
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
19
|
+
Project-URL: Changelog, https://github.com/m-lyon/hydra-lsp/blob/main/CHANGELOG.md
|
|
20
|
+
Project-URL: Repository, https://github.com/m-lyon/hydra-lsp
|
|
21
|
+
|
|
22
|
+
# Hydrust
|
|
23
|
+
|
|
24
|
+
A Language Server for [Hydra](https://hydra.cc/) configuration files, written in Rust.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
### Currently Implemented
|
|
29
|
+
|
|
30
|
+
- ✅ **YAML Parsing**: Extracts `_target_` references and their parameters
|
|
31
|
+
- ✅ **Hover Support**: Shows rich information when hovering over `_target_` values:
|
|
32
|
+
- Function signatures with parameter details
|
|
33
|
+
- Class information and docstrings
|
|
34
|
+
- Type annotations
|
|
35
|
+
- ✅ **Go to Definition**: Jump from YAML `_target_` to Python source file
|
|
36
|
+
- ✅ **Diagnostics**: Parameter validation including:
|
|
37
|
+
- Unknown parameters (unless `**kwargs` present)
|
|
38
|
+
- Missing required parameters
|
|
39
|
+
- Basic `_target_` format validation
|
|
40
|
+
- ✅ **Semantic Tokens**: Rich syntax highlighting for Hydra configurations:
|
|
41
|
+
- Module path components (namespace tokens)
|
|
42
|
+
- Class and function names
|
|
43
|
+
- Parameter keys (parameter tokens)
|
|
44
|
+
- Values (string, number, and property tokens)
|
|
45
|
+
- ✅ **Signature Help**: Shows parameter information while typing function arguments
|
|
46
|
+
|
|
47
|
+
### Planned Features
|
|
48
|
+
|
|
49
|
+
For a list of planned features and enhancements, see the [issues](https://github.com/m-lyon/hydra-lsp/issues) page.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
You can install `hydrust` through PyPI:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv tool install hydrust # or: pixi global install hydrust, pip install hydrust
|
|
57
|
+
uvx hydrust check conf/ # run once without installing
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
`hydrust` provides the `check` subcommand for one-time CLI and CI invocations, as well as an LSP for hydra diagnostics over stdin/stdout:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
hydrust check conf/ # diagnose configs on the command line
|
|
66
|
+
hydrust server # LSP
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `hydrust check`
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Check a single file
|
|
73
|
+
hydrust check config.yaml
|
|
74
|
+
|
|
75
|
+
# Check several files, or a whole directory tree
|
|
76
|
+
hydrust check config.yaml overrides.yaml
|
|
77
|
+
hydrust check conf/
|
|
78
|
+
|
|
79
|
+
# Specify workspace root for local module resolution
|
|
80
|
+
hydrust check config.yaml -w /path/to/project
|
|
81
|
+
|
|
82
|
+
# Specify Python interpreter for site-packages resolution
|
|
83
|
+
hydrust check config.yaml -p /path/to/venv/bin/python
|
|
84
|
+
|
|
85
|
+
# Enable detailed resolution tracing for debugging
|
|
86
|
+
hydrust check config.yaml --trace-resolution
|
|
87
|
+
|
|
88
|
+
# Change verbosity level (error, warn, info, debug, trace)
|
|
89
|
+
hydrust check config.yaml -v debug
|
|
90
|
+
|
|
91
|
+
# Output in different formats (pretty, json, compact, github)
|
|
92
|
+
hydrust check config.yaml -f json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Directories are searched recursively for `.yaml` and `.yml` files. The walk honours `.gitignore` and `.ignore` files within the directory being walked, and skips hidden files and directories such as `.github/`. Symlinks are followed.
|
|
96
|
+
|
|
97
|
+
#### Options
|
|
98
|
+
|
|
99
|
+
| Option | Description |
|
|
100
|
+
|--------|-------------|
|
|
101
|
+
| `-w, --workspace <PATH>` | Working directory for resolving Python modules |
|
|
102
|
+
| `-p, --python <PATH>` | Path to Python interpreter for module resolution |
|
|
103
|
+
| `-v, --verbosity <LEVEL>` | Logging verbosity: error, warn, info, debug, trace |
|
|
104
|
+
| `-f, --output-format <FORMAT>` | Output format: pretty (default), json, compact, github |
|
|
105
|
+
| `--trace-resolution` | Show detailed resolution steps for each target (written to stderr) |
|
|
106
|
+
| `--disable-rule <RULE>` | Disable a diagnostic rule; may be repeated |
|
|
107
|
+
|
|
108
|
+
When `--workspace` is omitted, `hydrust` resolves Python modules against the current directory.
|
|
109
|
+
|
|
110
|
+
#### Continuous integration
|
|
111
|
+
|
|
112
|
+
`--output-format github` emits GitHub Actions workflow commands, so
|
|
113
|
+
diagnostics appear as inline annotations on the pull request. A complete
|
|
114
|
+
workflow, run with `uvx` so nothing needs installing beyond uv itself:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
name: Hydra configs
|
|
118
|
+
|
|
119
|
+
on: [push, pull_request]
|
|
120
|
+
|
|
121
|
+
jobs:
|
|
122
|
+
hydrust:
|
|
123
|
+
runs-on: ubuntu-latest
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v6
|
|
126
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
127
|
+
- run: uvx hydrust@0.5.0 check --output-format github .
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`_target_` resolution needs the Python packages your configs point at. If they
|
|
131
|
+
are not in the checked-out tree, install the project first and point `hydrust`
|
|
132
|
+
at that interpreter with `--python`:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
- run: uv sync
|
|
136
|
+
- run: uvx hydrust@0.5.0 check --output-format github --python .venv/bin/python conf/
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Exit Codes
|
|
140
|
+
|
|
141
|
+
- `0`: No errors found
|
|
142
|
+
- `1`: One or more errors found
|
|
143
|
+
- `2`: Fatal error (path not found, invalid arguments, etc.)
|
|
144
|
+
|
|
145
|
+
Finding nothing to check is not an error: whether no YAML files matched at all
|
|
146
|
+
or none of the ones found are Hydra configs, `hydrust check` warns on stderr and
|
|
147
|
+
exits `0`.
|
|
148
|
+
|
|
149
|
+
## `hydrust server`
|
|
150
|
+
|
|
151
|
+
### Client Compatibility
|
|
152
|
+
|
|
153
|
+
A client can be pointed at any released server binary, and an old server quietly
|
|
154
|
+
ignores settings it was never taught to read. So the server describes itself in
|
|
155
|
+
`capabilities.experimental.hydrust` at `initialize` (`HydrustCapabilities::new`
|
|
156
|
+
in [src/backend.rs](src/backend.rs)):
|
|
157
|
+
|
|
158
|
+
- `protocolVersion` — the version of this block's shape.
|
|
159
|
+
- `supportedSettings` — keys read from `initializationOptions.settings`.
|
|
160
|
+
- `supportedRules` — codes accepted in `disabledRules`.
|
|
161
|
+
- `features` — optional behaviours switched on *for this session*, after matching
|
|
162
|
+
what the server can do against what the client asked for.
|
|
163
|
+
|
|
164
|
+
A client that sees the block uses it instead of any built-in table; servers
|
|
165
|
+
before v0.4.0 send no block, so clients fall back to a version table keyed on
|
|
166
|
+
`serverInfo.version` or `--version`. The reference client is the VS Code
|
|
167
|
+
extension ([hydra-lsp-vscode](https://github.com/m-lyon/hydra-lsp-vscode)), in
|
|
168
|
+
`src/common/compatTable.ts`.
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
173
|
+
|
|
174
|
+
## Acknowledgments
|
|
175
|
+
|
|
176
|
+
- Built with [tower-lsp](https://github.com/ebkalderon/tower-lsp) framework
|
|
177
|
+
- Python analysis design based on [ruff](https://github.com/astral-sh/ruff) and [ty](https://github.com/astral-sh/ty)
|
|
178
|
+
|
|
179
|
+
## References
|
|
180
|
+
|
|
181
|
+
- [Language Server Protocol Specification](https://microsoft.github.io/language-server-protocol/)
|
|
182
|
+
- [Hydra Documentation](https://hydra.cc/docs/intro/)
|
|
183
|
+
- [Tower-LSP Documentation](https://docs.rs/tower-lsp/)
|
|
184
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
hydrust/__init__.py,sha256=8Xu_M6_VjOSZHOoYTQraetcTMxTLJPSNc5cSa88JCwk,3075
|
|
2
|
+
hydrust/__main__.py,sha256=5eEUoWryFQw5eBLdz54FVk5sDQ8LFib-43tjjhf3QgM,585
|
|
3
|
+
hydrust/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
hydrust-0.5.0.data/scripts/hydrust.exe,sha256=BGU_OTfgEmbC7unUG23ViQca3nT7ZJ_MUQDqBqKLPEA,19102720
|
|
5
|
+
hydrust-0.5.0.dist-info/METADATA,sha256=ZZy-RiaRRt48pwOwRVJxoF1pHRvB5zVdKTCozz0Srug,6848
|
|
6
|
+
hydrust-0.5.0.dist-info/WHEEL,sha256=8Aej0W0a6Cz6apA3IzJrTnxLRVLAt-w0Oh8SA3Con_c,94
|
|
7
|
+
hydrust-0.5.0.dist-info/licenses/LICENSE,sha256=VAkE3wmVj-ViM_5N4pBBtmZjpw7vYTaNCDYq2fezuNk,1090
|
|
8
|
+
hydrust-0.5.0.dist-info/sboms/hydrust.cyclonedx.json,sha256=CnnS0FE84odLARb20P_K3xqBmFWRiq2HsG547fWqc1A,313733
|
|
9
|
+
hydrust-0.5.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Matthew Lyon
|
|
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.
|