Skip to content

Commit

Permalink
Upgarde for beancount3/beangulp fixes #135
Browse files Browse the repository at this point in the history
  • Loading branch information
tarioch committed Dec 30, 2024
1 parent f692d96 commit 7ed011c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changelog
=========
v0.6 (2024-12-27)
-----------------

Upgrade to beancount 3 and beangulp.


v0.5 (2024-01-21)
-----------------
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ packages = find:
setup_requires =
setuptools_scm
install_requires =
beancount>=2.3.5,<3.0.0
beancount>=3
beangulp
scikit-learn>=1.0
numpy>=1.18.0

Expand Down
2 changes: 1 addition & 1 deletion smart_importer/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging

from beancount.ingest import similar
from beangulp import similar

from smart_importer.hooks import ImporterHook

Expand Down
8 changes: 3 additions & 5 deletions smart_importer/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ def apply_hooks(importer, hooks):
unpatched_extract = importer.extract

@wraps(unpatched_extract)
def patched_extract_method(file, existing_entries=None):
def patched_extract_method(filepath, existing=None):
logger.debug("Calling the importer's extract method.")
imported_entries = unpatched_extract(
file, existing_entries=existing_entries
)
imported_entries = unpatched_extract(filepath, existing=existing)

for hook in hooks:
imported_entries = hook(
importer, file, imported_entries, existing_entries
importer, filepath, imported_entries, existing
)

return imported_entries
Expand Down
2 changes: 1 addition & 1 deletion smart_importer/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __call__(self, importer, file, imported_entries, existing_entries):
A list of entries, modified by this predictor.
"""
logging.debug("Running %s for file %s", self.__class__.__name__, file)
self.account = importer.file_account(file)
self.account = importer.account(file)
self.load_training_data(existing_entries)
with self.lock:
self.define_pipeline()
Expand Down
2 changes: 1 addition & 1 deletion tests/data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import pytest
from beancount.core.compare import stable_hash_namedtuple
from beancount.ingest.importer import ImporterProtocol
from beancount.parser import parser
from beangulp.importer import ImporterProtocol

from smart_importer import PredictPostings, apply_hooks

Expand Down
2 changes: 1 addition & 1 deletion tests/predictors_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Tests for the `PredictPayees` and the `PredictPostings` decorator"""

# pylint: disable=missing-docstring
from beancount.ingest.importer import ImporterProtocol
from beancount.parser import parser
from beangulp.importer import ImporterProtocol

from smart_importer import PredictPayees, PredictPostings
from smart_importer.hooks import apply_hooks
Expand Down

0 comments on commit 7ed011c

Please sign in to comment.