beancount-ast 0.0.1a2__tar.gz → 0.0.1a4__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.
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/renovate.json +0 -6
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.gitignore +1 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.pre-commit-config.yaml +2 -2
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/AGENTS.md +12 -17
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/Cargo.lock +136 -595
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/Cargo.toml +2 -10
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/PKG-INFO +1 -1
- beancount_ast-0.0.1a4/py-src/beancount_ast/__init__.py +88 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/py-src/beancount_ast/_ast.pyi +172 -215
- beancount_ast-0.0.1a4/py-src/beancount_ast/_directive.py +58 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/pyproject.toml +3 -3
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/src/lib.rs +121 -220
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/__snapshots__/test_parse_snapshots.ambr +3 -15
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/test_parse_snapshots.py +0 -9
- beancount_ast-0.0.1a2/py-src/beancount_ast/__init__.py +0 -83
- beancount_ast-0.0.1a2/scripts/generate_ast_stubs.py +0 -58
- beancount_ast-0.0.1a2/src/bin/stub_gen.rs +0 -6
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/_build_wheels.yaml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/autofix.yaml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/ci.yml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/release.yaml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/tests.yml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/README.md +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/dprint.json +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/py-src/beancount_ast/py.typed +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/taskfile.yaml +0 -0
- {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/__init__.py +0 -0
|
@@ -15,7 +15,7 @@ repos:
|
|
|
15
15
|
always_run: true
|
|
16
16
|
|
|
17
17
|
- repo: https://github.com/abravalheri/validate-pyproject
|
|
18
|
-
rev: v0.
|
|
18
|
+
rev: v0.25
|
|
19
19
|
hooks:
|
|
20
20
|
- id: validate-pyproject
|
|
21
21
|
language: python
|
|
@@ -57,7 +57,7 @@ repos:
|
|
|
57
57
|
|
|
58
58
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
59
59
|
# Ruff version.
|
|
60
|
-
rev: v0.
|
|
60
|
+
rev: v0.15.0
|
|
61
61
|
hooks:
|
|
62
62
|
# Run the linter.
|
|
63
63
|
- id: ruff
|
|
@@ -5,38 +5,33 @@
|
|
|
5
5
|
- The Python API intentionally exposes the **parser AST** (directives + spans + raw tokens), not Beancount’s semantic `beancount.core` model.
|
|
6
6
|
|
|
7
7
|
## Key layout
|
|
8
|
-
- `src/lib.rs`:
|
|
8
|
+
- `src/lib.rs`: PyO3 module `beancount_ast._ast`.
|
|
9
9
|
- Registers all exposed Python classes in `#[pymodule(name = "_ast")]`.
|
|
10
|
-
- Converts
|
|
11
|
-
-
|
|
12
|
-
- `py-src/beancount_ast/__init__.py`: re-exports symbols
|
|
13
|
-
- `py-src/beancount_ast/
|
|
14
|
-
- `
|
|
10
|
+
- Converts `beancount_parser::ast::*` nodes into `Py*` wrappers.
|
|
11
|
+
- Exposes `parse_string` and `parse_file` to Python.
|
|
12
|
+
- `py-src/beancount_ast/__init__.py`: re-exports compiled `_ast` symbols and the `Directive` ABC for consumers.
|
|
13
|
+
- `py-src/beancount_ast/_directive.py`: defines the `Directive` ABC and registers all directive classes.
|
|
14
|
+
- `py-src/beancount_ast/_ast.pyi`: canonical type stubs mirroring the compiled `beancount_ast._ast` extension.
|
|
15
|
+
- `tests/test_parse_snapshots.py`: snapshot-style API tests (`pytest` + `syrupy`).
|
|
15
16
|
|
|
16
17
|
## Workflows (local + CI-aligned)
|
|
17
|
-
-
|
|
18
|
+
- Running python tests.
|
|
18
19
|
- Setup: `uv sync --dev --no-install-project`
|
|
19
|
-
-
|
|
20
|
+
- Re-build module after any rust code change: `maturin develop --locked --release --uv -v`
|
|
21
|
+
- Run tests: `pytest`
|
|
20
22
|
- Rust checks mirror CI (`.github/workflows/ci.yml`):
|
|
21
23
|
- Format: `cargo fmt --all -- --check`
|
|
22
24
|
- Lint: `cargo clippy --workspace --all-targets --all-features -- -D warnings`
|
|
23
25
|
|
|
24
26
|
## Conventions to follow when changing Rust bindings
|
|
25
|
-
- Avoid `unwrap()` / `expect()`; the crate denies them (`src/lib.rs` has `#![deny(clippy::unwrap_used, clippy::expect_used)]`).
|
|
27
|
+
- Avoid `unwrap()` / `expect()` / `unwrap_of_default()`; the crate denies them (`src/lib.rs` has `#![deny(clippy::unwrap_used, clippy::expect_used)]`), the error should be propagated to caller.
|
|
26
28
|
- Python-facing data structures are thin, mostly immutable “record” types:
|
|
27
29
|
- Define a `Py*` struct with `#[pyclass(..., get_all)]` and `pyderive` derives (`PyNew`, `PyRepr`, `PyStr`, and sometimes `PyEq`).
|
|
28
|
-
-
|
|
30
|
+
- when you update rust code, you should also update type stub.
|
|
29
31
|
- When adding a new directive/type:
|
|
30
32
|
1) Add the `Py*` struct.
|
|
31
33
|
2) Register it in the `_ast` module init.
|
|
32
34
|
3) Extend the conversion layer (e.g. `directive_to_py(...)`).
|
|
33
|
-
4) Update the `Directive` type alias used for stubs (see the `stub-gen` block at the end of `src/lib.rs`).
|
|
34
|
-
|
|
35
|
-
## Stub generation
|
|
36
|
-
- The stub generator binary is `src/bin/stub_gen.rs` and is only available with the `stub-gen` feature.
|
|
37
|
-
- Typical command:
|
|
38
|
-
- `cargo run --bin stub_gen --features stub-gen`
|
|
39
|
-
- The generated output updates `py-src/beancount_ast/_ast.pyi`.
|
|
40
35
|
|
|
41
36
|
## Formatting / linting
|
|
42
37
|
- Non-code config formatting uses `dprint` (see `dprint.json`) and is enforced via pre-commit.
|