lean-runtime 0.6.0__py3-none-any.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.
- lean_runtime/__init__.py +67 -0
- lean_runtime/__main__.py +4 -0
- lean_runtime/backends.py +373 -0
- lean_runtime/cli.py +254 -0
- lean_runtime/diagnostics.py +52 -0
- lean_runtime/environments.py +1170 -0
- lean_runtime/errors.py +63 -0
- lean_runtime/events.py +35 -0
- lean_runtime/health.py +86 -0
- lean_runtime/lake.py +43 -0
- lean_runtime/lockfiles.py +192 -0
- lean_runtime/locking.py +82 -0
- lean_runtime/models.py +78 -0
- lean_runtime/policies.py +36 -0
- lean_runtime/py.typed +1 -0
- lean_runtime/references.py +246 -0
- lean_runtime/resolver.py +282 -0
- lean_runtime/runtime.py +430 -0
- lean_runtime/serialization.py +51 -0
- lean_runtime/specs.py +210 -0
- lean_runtime/store.py +462 -0
- lean_runtime/toolchains.py +164 -0
- lean_runtime-0.6.0.dist-info/METADATA +332 -0
- lean_runtime-0.6.0.dist-info/RECORD +28 -0
- lean_runtime-0.6.0.dist-info/WHEEL +5 -0
- lean_runtime-0.6.0.dist-info/entry_points.txt +2 -0
- lean_runtime-0.6.0.dist-info/licenses/LICENSE +202 -0
- lean_runtime-0.6.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Best-effort normalization of Lean's version-dependent diagnostics."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from .models import Diagnostic, Severity
|
|
8
|
+
|
|
9
|
+
_HEADER = re.compile(
|
|
10
|
+
r"^(?P<file>.*?):(?P<line>\d+):(?P<column>\d+): "
|
|
11
|
+
r"(?P<severity>error|warning|information):\s*(?P<message>.*)$"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def parse_diagnostics(output: str) -> tuple[Diagnostic, ...]:
|
|
16
|
+
"""Parse ordinary Lean diagnostic headers and their continuation lines.
|
|
17
|
+
|
|
18
|
+
Lean does not expose one stable machine-readable diagnostic format across
|
|
19
|
+
all supported releases. Unknown output remains available verbatim on the
|
|
20
|
+
execution result rather than being discarded.
|
|
21
|
+
"""
|
|
22
|
+
diagnostics: list[Diagnostic] = []
|
|
23
|
+
current: dict[str, object] | None = None
|
|
24
|
+
|
|
25
|
+
def finish() -> None:
|
|
26
|
+
nonlocal current
|
|
27
|
+
if current is not None:
|
|
28
|
+
diagnostics.append(Diagnostic(**current)) # type: ignore[arg-type]
|
|
29
|
+
current = None
|
|
30
|
+
|
|
31
|
+
for line in output.splitlines():
|
|
32
|
+
match = _HEADER.match(line)
|
|
33
|
+
if match:
|
|
34
|
+
finish()
|
|
35
|
+
current = {
|
|
36
|
+
"severity": match.group("severity"),
|
|
37
|
+
"message": match.group("message"),
|
|
38
|
+
"file": match.group("file"),
|
|
39
|
+
"line": int(match.group("line")),
|
|
40
|
+
"column": int(match.group("column")),
|
|
41
|
+
}
|
|
42
|
+
elif current is not None:
|
|
43
|
+
message = str(current["message"])
|
|
44
|
+
current["message"] = f"{message}\n{line}" if line else message
|
|
45
|
+
finish()
|
|
46
|
+
return tuple(diagnostics)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def error_diagnostic(message: str) -> Diagnostic:
|
|
50
|
+
"""Create an infrastructure diagnostic."""
|
|
51
|
+
severity: Severity = "error"
|
|
52
|
+
return Diagnostic(severity=severity, message=message)
|