Unexpected Inheritance Problem
Chris Angelico
rosuav at gmail.com
Thu May 20 01:58:42 EDT 2021
On Thu, May 20, 2021 at 2:02 PM Richard Damon <Richard at damon-family.org> wrote:
>
> Given the following definition of classes, I am getting an unexpected
> error of :
>
> TypeError: __init__() missing 2 required keyword-only arguments:
> 'idcode' and 'tag'
>
> On the call to create a GedcomHead in the call to GedcomHead() in
> Gedcom0Tag.add()
>
> class Gedcom0Tag(GedcomTag):
> """Represents a Level 0 Tag of a GEDCOM file"""
>
> @classmethod
> def add(cls, *, parent, tag: str, payload: str, level=0):
>
> Gedcom0Tag.add(parent, 'Head', '')
>
You're defining that add takes keyword-only args (because the asterisk
stops them from being passed positionally), but then you're calling it
with nothing but positional args. Is that the code you're using? I
would expect to see *three* missing kwonly args from this.
ChrisA
More information about the Python-list
mailing list