Ciao Stefano,

thank you for sharing your code with me. I had a quick look and I think I see what is going wrong. However, the code you sent is not self contained (it depends on code that was not included in the tarball) thus I was not able to properly test things.

On 09/07/24 08:44, Stefano Zacchiroli wrote:
Nice catch, that was indeed it for this specific error. Next one up
(after passing the account name as single parameter for the
constructor)

In the importer class definitions in the code you sent me the class constructors do not take any parameter. I had to remove the parameters passed to the constructor to make it work.

is:

   TypeError: Can't instantiate abstract class AmexImporter with abstract 
method account

It looks like the protocol is significantly different wrt the previous
version. But I'll send you my example code offlist, as you suggested in
previous email. Thanks!

Yes! The beangulp.Importer protocol is different from the old beangulp.ImporterProtocol (otherwise there would not have been any need to rename the interface).

The old protocol is defined here:

https://github.com/beancount/beangulp/blob/ec3752930efdfa7358890e263f1aba16151ae316/beangulp/importer.py#L167-L199

The new protocol is defined here:

https://github.com/beancount/beangulp/blob/ec3752930efdfa7358890e263f1aba16151ae316/beangulp/importer.py#L20-L164

As you can see, some methods have been renamed. The other important change, is that beangulp.Importer is now an ABC, thus the implementation will check that any subclass implements the expected interface when it is instantiated.

At a quick look, it seems that you changed your importers base class from deriving from beancount.ingest.ImporterProtocol (or similar, I don't remember the exact import path) to beangulp.Importer but kept the implementation unchanged. This is not expected to work.

What works is to keep the implementation unchanged and derive from beangulp.ImporterProtocol or update the implementation to the interface defined in beangulp.Importer and derive from this ABC.

If I change your mybeancount.private.ingest.importers.CsvImporter to derive from beangulp.ImporterProtocol I can execute bean-extract.py.

Alternatively, mybeancount.private.ingest.importers.CsvImporter can derive from beangulp.Importer but the file_account() method needs to be renamed account() (which requires to rename the account class member to something else).

I hope this helps.

Cheers,
Dan

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/6d1a0139-6d88-4390-b082-8d96f105680e%40grinta.net.

Reply via email to