My bad - and apologies to the smart_importer contributors!

The issue I ran into is that the hook function call signature 
<https://github.com/beancount/beangulp/blob/master/beangulp/__init__.py#L103-L105>
 
seems to have changed in beangulp v3. It's called with two args for the 
extracted and existing entries:

    # Invoke hooks.
    for func in ctx.hooks:
        extracted = func(extracted, existing_entries)

But smart_importer's EntryPredictor is expecting four args 
<https://github.com/beancount/smart_importer/blob/main/smart_importer/predictor.py#L75-L81>
 
in __call__:

    def __call__(
            self,
            importer: Importer,
            file: str,
            imported_entries: data.Directives,
            existing_entries: data.Directives,
        ) -> data.Directives:

So I get an exception when trying to use it:

    TypeError: EntryPredictor.__call__() missing 2 required positional 
arguments: 'imported_entries' and 'existing_entries'

For now, I have derived my own class from PredictPostings and overridden 
__call__ to omit the importer and file arguments, but I just copied the 
implementation of __call__, which I don't like.

On Saturday, January 11, 2025 at 3:43:59 AM UTC-5 Red S wrote:

> But I'm not using this in production yet as I'm trying to write the 
> equivalent of Red S's smart importer to predict the category account.
>
>
> While I use smart_importer a lot and find it to be excellent what what it 
> does, I had nothing to do with writing it. The authors and contributors can 
> be found in the repo <https://github.com/beancount/smart_importer> :).
>
> BTW, curious, what aspect of it is not working for you? Seems to me like 
> it should work out of the box for your use case.
> ​
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/beancount/8f4eb5a0-8d1e-485b-aeb3-eddb58ccd146n%40googlegroups.com.

Reply via email to