fix(deps): make beangulp (and transitive beancount) optional#186
Merged
Conversation
`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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #146.
pip install rustfavapulled inbeancounttransitively (rustfava → beangulp → beancount), which defeats the "alternative to beancount" point and fails to build on some platforms (alpine, per the issue).beancountwas already optional (beancount-compat), butbeangulpwas a hard dependency dragging it back in. beangulp is only used by the file import/ingest feature.Changes
pyproject.toml: movebeangulpfrom coredependenciesto a newingestoptional extra (added to thetestgroup 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 ownBeanImporterProtocolimporters are unaffected.cachefalls back toNone.load_import_config/get_cached_fileraise a clearIngestUnavailableError("install rustfava[ingest]") instead of a crypticImportError.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
RustfavaLedgerbuilds, entries parse, no errors; andimport beangulpcorrectly fails, proving the block.main); mypy clean on the changed file.