Skip to content

fix(deps): make beangulp (and transitive beancount) optional#186

Merged
robcohen merged 3 commits into
mainfrom
fix/146-optional-beangulp
Jun 19, 2026
Merged

fix(deps): make beangulp (and transitive beancount) optional#186
robcohen merged 3 commits into
mainfrom
fix/146-optional-beangulp

Conversation

@robcohen

Copy link
Copy Markdown
Member

Closes #146.

pip install rustfava pulled in beancount transitively (rustfava → beangulp → beancount), which defeats the "alternative to beancount" point and fails to build on some platforms (alpine, per the issue). beancount was already optional (beancount-compat), but beangulp was a hard dependency dragging it back in. beangulp is only used by the file import/ingest feature.

Changes

  • pyproject.toml: move beangulp from core dependencies to a new ingest optional extra (added to the test group so CI still exercises it).
  • core/ingest.py (on the always-loaded path, so it must import without beangulp):
    • Importer → a placeholder class when beangulp is absent. Nothing is an instance of it, so beangulp-style importers are never matched; rustfava's own BeanImporterProtocol importers are unaffected.
    • cache falls back to None.
    • load_import_config / get_cached_file raise a clear IngestUnavailableError ("install rustfava[ingest]") instead of a cryptic ImportError.
  • docs: document rustfava[ingest] for the import UI.

Result

  • pip install rustfava → no beancount, ledgers load and queries run.
  • pip install 'rustfava[ingest]' → full file-import support.

Verification

  • A full ledger loads with beangulp + beancount blocked (import-hook simulation) — RustfavaLedger builds, entries parse, no errors; and import beangulp correctly fails, proving the block.
  • The 11 ingest tests pass with beangulp present; full suite 497 passed.
  • ruff adds zero new violations (the one UP047 is pre-existing on main); mypy clean on the changed file.

`pip install rustfava` pulled in `beancount` transitively via `beangulp`, which
defeats the point of being a beancount alternative — and beancount's build
fails on some platforms (e.g. alpine). beangulp is only used by the file
import/ingest feature.

Move `beangulp` from the core dependencies to a new `ingest` optional extra.
`core/ingest.py` is on the always-loaded path, so guard its beangulp imports:
- `Importer` becomes a placeholder class when beangulp is absent (nothing is an
  instance of it, so beangulp-style importers are simply never matched;
  rustfava's own `BeanImporterProtocol` importers are unaffected);
- the `cache` import falls back to `None`;
- the import entry points (`load_import_config`, `get_cached_file`) raise a
  clear `IngestUnavailableError` ("install rustfava[ingest]") instead of a
  cryptic ImportError.

So a plain `rustfava` install no longer drags in beancount just to view
ledgers; `pip install 'rustfava[ingest]'` enables file import. Docs updated.

Verified: a full ledger loads with beangulp+beancount blocked; the ingest
tests pass with beangulp present; full suite green (497).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
robcohen and others added 2 commits June 19, 2026 13:56
CI fixes for the beangulp-optional change:
- mypy (lint-python-types): removing beangulp from core deps also removed
  beancount transitively from the `types` group's env, so mypy could no longer
  resolve the (guarded) beancount imports. Add rustfava[ingest] +
  rustfava[beancount-compat] to the `types` group to restore it.
- coverage: the new `IngestUnavailableError` guards dropped coverage below
  100%. Make the runtime guards testable (drop their pragma) and add a test
  exercising both entry points with beangulp absent; pragma the import-time
  cache fallback that can't be hit with the dependency present.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@robcohen robcohen merged commit 5361781 into main Jun 19, 2026
30 checks passed
@robcohen robcohen deleted the fix/146-optional-beangulp branch June 19, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove transitive dependency on beancount

1 participant