beancount_ast 0.0.1a5__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.
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>trim21/renovate-config",
5
+ "github>trim21/renovate-config:python",
6
+ "github>trim21/renovate-config:rust"
7
+ ],
8
+ "lockFileMaintenance": {
9
+ "enabled": true
10
+ },
11
+ "cargo": {
12
+ "enabled": true
13
+ },
14
+ "rangeStrategy": "bump",
15
+ "packageRules": [
16
+ {
17
+ "matchDepTypes": [
18
+ "requires-python"
19
+ ],
20
+ "enabled": false
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,83 @@
1
+ name: Build Python Wheels
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ jobs:
7
+ sdist:
8
+ runs-on: ubuntu-24.04
9
+ steps:
10
+ - uses: actions/checkout@v6
11
+ - name: Set up Python ${{ matrix.python-version }}
12
+ uses: actions/setup-python@v6
13
+ with:
14
+ python-version: '3.14'
15
+ - name: Build sdist
16
+ uses: PyO3/maturin-action@v1
17
+ with:
18
+ command: sdist
19
+ args: --out dist
20
+ - name: Upload sdist
21
+ uses: actions/upload-artifact@v6
22
+ with:
23
+ name: wheels-sdist
24
+ path: dist
25
+
26
+ wheel:
27
+ runs-on: ${{ matrix.platform.runner }}
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ platform:
32
+ - runner: macos-15
33
+ target: aarch64
34
+ - runner: macos-15-intel
35
+ target: x64
36
+
37
+ - runner: windows-latest
38
+ target: x64
39
+ - runner: windows-11-arm
40
+ target: aarch64
41
+
42
+ - runner: ubuntu-24.04
43
+ target: x64
44
+ - runner: ubuntu-24.04-arm
45
+ target: aarch64
46
+
47
+ steps:
48
+ - uses: actions/checkout@v6
49
+
50
+ - uses: actions-rust-lang/setup-rust-toolchain@v1
51
+ if: ${{ runner.os != 'Linux' }}
52
+
53
+ - uses: actions/setup-python@v6
54
+ if: ${{ runner.os != 'Linux' }}
55
+ with:
56
+ python-version: '3.14'
57
+
58
+ - name: Build wheels
59
+ uses: PyO3/maturin-action@v1
60
+ with:
61
+ target: ${{ matrix.platform.target }}
62
+ args: --release --out dist
63
+ # https://github.com/tree-sitter/tree-sitter/issues/4186
64
+ manylinux: '2_28'
65
+
66
+ - run: ls -ahl dist
67
+ shell: bash
68
+
69
+ - name: Upload wheels
70
+ uses: actions/upload-artifact@v6
71
+ with:
72
+ name: wheels-${{ runner.os }}-${{ matrix.platform.target }}
73
+ path: dist
74
+
75
+ merge-wheel-artifact:
76
+ runs-on: ubuntu-24.04
77
+ needs: ['sdist', 'wheel']
78
+ steps:
79
+ - name: Merge Artifacts
80
+ uses: actions/upload-artifact/merge@v6
81
+ with:
82
+ name: wheel
83
+ pattern: wheels-*
@@ -0,0 +1,27 @@
1
+ name: autofix.ci
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ autofix:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v6
17
+
18
+ - uses: actions-rust-lang/setup-rust-toolchain@v1
19
+ with:
20
+ components: rustfmt,clippy
21
+
22
+ - run: uv tool run prek -- run -a || true
23
+ - run: cargo fmt || true
24
+ - run: cargo clippy --fix --allow-dirty || true
25
+ - run: cargo fmt || true
26
+
27
+ - uses: autofix-ci/action@v1
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref_name }}
13
+ cancel-in-progress: true
14
+
15
+ env:
16
+ CARGO_TERM_COLOR: always
17
+
18
+ jobs:
19
+ rust:
20
+ name: Rust fmt, lint, tests
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v6
24
+
25
+ - uses: actions-rust-lang/setup-rust-toolchain@v1
26
+
27
+ - name: Format (cargo fmt)
28
+ run: cargo fmt --all -- --check
29
+
30
+ - name: Lint (clippy)
31
+ run: cargo clippy --workspace --all-targets --all-features -- -D warnings
32
+
33
+ pre-commit:
34
+ runs-on: ubuntu-24.04
35
+ steps:
36
+ - uses: actions/checkout@v6
37
+
38
+ - uses: trim21/actions/prek@master
@@ -0,0 +1,27 @@
1
+ name: publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - 'v*'
8
+
9
+ jobs:
10
+ build:
11
+ uses: ./.github/workflows/_build_wheels.yaml
12
+
13
+ upload_all:
14
+ name: Upload wheels to PyPI
15
+ needs: [build]
16
+ runs-on: ubuntu-slim
17
+ permissions:
18
+ contents: write
19
+ id-token: write
20
+ steps:
21
+ - uses: actions/download-artifact@v7
22
+ with:
23
+ name: wheel
24
+ path: dist
25
+
26
+ - uses: astral-sh/setup-uv@v7
27
+ - run: uv publish
@@ -0,0 +1,71 @@
1
+ name: Python Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ concurrency:
15
+ group: ${{ github.workflow }}-${{ github.ref_name }}
16
+ cancel-in-progress: true
17
+
18
+ env:
19
+ CARGO_TERM_COLOR: always
20
+
21
+ jobs:
22
+ build-wheel:
23
+ uses: ./.github/workflows/_build_wheels.yaml
24
+
25
+ tests:
26
+ name: Tests (wheel install)
27
+ needs:
28
+ - build-wheel
29
+ runs-on: ${{ matrix.platform }}
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ python:
34
+ - '3.10'
35
+ - '3.11'
36
+ - '3.12'
37
+ - '3.13'
38
+ - '3.14'
39
+ platform:
40
+ - macos-15
41
+ - macos-15-intel
42
+ - windows-latest
43
+ - windows-11-arm
44
+ - ubuntu-24.04
45
+ - ubuntu-24.04-arm
46
+ exclude:
47
+ - platform: windows-11-arm
48
+ python: '3.10'
49
+ steps:
50
+ - uses: actions/checkout@v6
51
+
52
+ - uses: actions/download-artifact@v7
53
+ with:
54
+ name: wheel
55
+ path: dist
56
+
57
+ - uses: actions/setup-python@v6
58
+ with:
59
+ python-version: '${{ matrix.python }}'
60
+
61
+ - name: Install the latest version of uv
62
+ uses: astral-sh/setup-uv@v7
63
+ with:
64
+ activate-environment: 'true'
65
+
66
+ - run: uv sync --dev --no-install-project
67
+
68
+ - name: Install wheel
69
+ run: uv pip install beancount-ast --no-index --find-links ./dist/
70
+
71
+ - run: pytest
@@ -0,0 +1,30 @@
1
+ *.DS_Store
2
+ *.a
3
+ *.picklecache
4
+ *.pyc
5
+ *.so
6
+ *.pyd
7
+ *.swp
8
+ *~
9
+ .cache
10
+ .idea
11
+ .vscode/
12
+ .noseids
13
+ .pytest_cache/*
14
+ TAGS
15
+ bazel-*
16
+ beancount.egg-info
17
+ beancount/parser/grammar.output
18
+ beancount/parser/tokens_test
19
+ beancount/parser/*.o
20
+ build
21
+ dist
22
+ examples/generated/*
23
+ experiments/v3/arrow/*.feather
24
+ experiments/v3/arrow/*.parquet
25
+ experiments/v3/arrow/*.arrow
26
+ .aider*
27
+ .env
28
+ target
29
+ uv.lock
30
+ .envrc
@@ -0,0 +1,69 @@
1
+ exclude: '.*/__snapshots__/.*'
2
+
3
+ repos:
4
+ - repo: https://github.com/trim21/pre-commit-mirror-meson
5
+ rev: 'v1.10.1'
6
+ hooks:
7
+ - id: meson-fmt
8
+ args: ['--inplace', '--editor-config']
9
+
10
+ - repo: https://github.com/trim21/dprint-pre-commit
11
+ rev: 'v0.51.1.0'
12
+ hooks:
13
+ - id: dprint
14
+ pass_filenames: false
15
+ always_run: true
16
+
17
+ - repo: https://github.com/abravalheri/validate-pyproject
18
+ rev: v0.25
19
+ hooks:
20
+ - id: validate-pyproject
21
+ language: python
22
+ # Optional extra validations from SchemaStore:
23
+ additional_dependencies:
24
+ - 'validate-pyproject-schema-store[all]==2026.1.22'
25
+ args:
26
+ - --disable
27
+ - ruff
28
+
29
+ - repo: https://github.com/pre-commit/pre-commit-hooks
30
+ rev: v6.0.0
31
+ hooks:
32
+ - id: check-case-conflict
33
+ - id: check-ast
34
+ - id: check-builtin-literals
35
+ - id: check-toml
36
+ - id: check-yaml
37
+ - id: check-json
38
+ - id: check-docstring-first
39
+ - id: check-merge-conflict
40
+ - id: check-added-large-files # check for file bigger than 500kb
41
+ - id: debug-statements
42
+ - id: trailing-whitespace
43
+ exclude: '.*\.bin'
44
+ - id: mixed-line-ending
45
+ args: [--fix=lf]
46
+ exclude: '.*\.bin'
47
+ - id: end-of-file-fixer
48
+ exclude: '.*\.bin'
49
+ - id: fix-byte-order-marker
50
+ exclude: '.*\.bin'
51
+
52
+ - repo: https://github.com/pre-commit/mirrors-clang-format
53
+ rev: v21.1.8
54
+ hooks:
55
+ - id: clang-format
56
+ types_or: [c++, c, cuda]
57
+
58
+ - repo: https://github.com/astral-sh/ruff-pre-commit
59
+ # Ruff version.
60
+ rev: v0.15.0
61
+ hooks:
62
+ # Run the linter.
63
+ - id: ruff
64
+ args: [--fix]
65
+
66
+ - repo: https://github.com/psf/black
67
+ rev: '26.1.0'
68
+ hooks:
69
+ - id: black
@@ -0,0 +1,42 @@
1
+ # Copilot instructions (beancount-ast)
2
+
3
+ ## Project overview
4
+ - This repo provides Python bindings (PyO3) for the Rust `beancount-parser` directive AST.
5
+ - The Python API intentionally exposes the **parser AST** (directives + spans + raw tokens), not Beancount’s semantic `beancount.core` model.
6
+
7
+ ## Key layout
8
+ - `src/lib.rs`: PyO3 module `beancount_ast._ast`.
9
+ - Registers all exposed Python classes in `#[pymodule(name = "_ast")]`.
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`).
16
+
17
+ ## Workflows (local + CI-aligned)
18
+ - Running python tests.
19
+ - Setup: `uv sync --dev --no-install-project`
20
+ - Re-build module after any rust code change: `maturin develop --locked --release --uv -v`
21
+ - Run tests: `pytest`
22
+ - Rust checks mirror CI (`.github/workflows/ci.yml`):
23
+ - Format: `cargo fmt --all -- --check`
24
+ - Lint: `cargo clippy --workspace --all-targets --all-features -- -D warnings`
25
+
26
+ ## Conventions to follow when changing Rust bindings
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.
28
+ - Python-facing data structures are thin, mostly immutable “record” types:
29
+ - Define a `Py*` struct with `#[pyclass(..., get_all)]` and `pyderive` derives (`PyNew`, `PyRepr`, `PyStr`, and sometimes `PyEq`).
30
+ - when you update rust code, you should also update type stub.
31
+ - When adding a new directive/type:
32
+ 1) Add the `Py*` struct.
33
+ 2) Register it in the `_ast` module init.
34
+ 3) Extend the conversion layer (e.g. `directive_to_py(...)`).
35
+
36
+ ## Formatting / linting
37
+ - Non-code config formatting uses `dprint` (see `dprint.json`) and is enforced via pre-commit.
38
+ - Python formatting/linting uses `ruff` + `black` (see `.pre-commit-config.yaml`).
39
+
40
+ ## Release notes (when relevant)
41
+ - CI builds wheels via `maturin` (see `.github/workflows/_build_wheels.yaml`).
42
+ - Tags `v*` publish to PyPI (see `.github/workflows/release.yaml`).