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.
Files changed (27) hide show
  1. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/renovate.json +0 -6
  2. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.gitignore +1 -0
  3. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.pre-commit-config.yaml +2 -2
  4. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/AGENTS.md +12 -17
  5. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/Cargo.lock +136 -595
  6. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/Cargo.toml +2 -10
  7. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/PKG-INFO +1 -1
  8. beancount_ast-0.0.1a4/py-src/beancount_ast/__init__.py +88 -0
  9. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/py-src/beancount_ast/_ast.pyi +172 -215
  10. beancount_ast-0.0.1a4/py-src/beancount_ast/_directive.py +58 -0
  11. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/pyproject.toml +3 -3
  12. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/src/lib.rs +121 -220
  13. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/__snapshots__/test_parse_snapshots.ambr +3 -15
  14. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/test_parse_snapshots.py +0 -9
  15. beancount_ast-0.0.1a2/py-src/beancount_ast/__init__.py +0 -83
  16. beancount_ast-0.0.1a2/scripts/generate_ast_stubs.py +0 -58
  17. beancount_ast-0.0.1a2/src/bin/stub_gen.rs +0 -6
  18. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/_build_wheels.yaml +0 -0
  19. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/autofix.yaml +0 -0
  20. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/ci.yml +0 -0
  21. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/release.yaml +0 -0
  22. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/.github/workflows/tests.yml +0 -0
  23. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/README.md +0 -0
  24. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/dprint.json +0 -0
  25. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/py-src/beancount_ast/py.typed +0 -0
  26. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/taskfile.yaml +0 -0
  27. {beancount_ast-0.0.1a2 → beancount_ast-0.0.1a4}/tests/__init__.py +0 -0
@@ -18,12 +18,6 @@
18
18
  "requires-python"
19
19
  ],
20
20
  "enabled": false
21
- },
22
- {
23
- "matchDepNames": [
24
- "beancount-parser"
25
- ],
26
- "enabled": false
27
21
  }
28
22
  ]
29
23
  }
@@ -27,3 +27,4 @@ experiments/v3/arrow/*.arrow
27
27
  .env
28
28
  target
29
29
  uv.lock
30
+ .envrc
@@ -15,7 +15,7 @@ repos:
15
15
  always_run: true
16
16
 
17
17
  - repo: https://github.com/abravalheri/validate-pyproject
18
- rev: v0.24.1
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.14.14
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`: the PyO3 module `beancount_ast._ast`.
8
+ - `src/lib.rs`: PyO3 module `beancount_ast._ast`.
9
9
  - Registers all exposed Python classes in `#[pymodule(name = "_ast")]`.
10
- - Converts Rust parser nodes (`beancount_parser::ast::*`) into `Py*` structs.
11
- - Public Python entrypoints are `parse_string` and `parse_file`.
12
- - `py-src/beancount_ast/__init__.py`: re-exports symbols from `beancount_ast._ast`.
13
- - `py-src/beancount_ast/_ast.pyi`: stubs of `src/lib.rs`, when you change any interface, you should also update it.
14
- - `tests/test_parse_snapshots.py`: snapshot-style API tests using `pytest` + `syrupy`.
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
- - Python deps / test env are managed with `uv` (see `.github/workflows/tests.yml`).
18
+ - Running python tests.
18
19
  - Setup: `uv sync --dev --no-install-project`
19
- - Run tests: `uv run pytest`
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
- - If the type should appear in stubs, add `#[cfg_attr(feature = "stub-gen", ...gen_stub_pyclass)]`.
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.