Skip to content

multiple inheritance requires to **kwargs in any case #33

Open

Description

@AnNeub

If using multiple inheritance than the **kwargs need to be generated independent from eSuperTypes

{%- macro generate_class_init_args(c) -%}
    {% if c.eStructuralFeatures | list  %}, *, {% endif -%}
    {{ c.eStructuralFeatures | map(attribute='name') | map('re_sub', '$', '=None') | join(', ') }}
    {%- if c.eSuperTypes %}, **kwargs{% endif %}
{%- endmacro %}

{%- macro generate_super_init_args(c, user_module=False) -%}
    {%- if user_module and c.eStructuralFeatures -%}
    {{ c.eStructuralFeatures | map(attribute='name') | map('re_sub', '(.+)', '\g<0>= \g<0>') | join(', ') }}
    {%- endif %}
    {%- if c.eSuperTypes %}{{', ' if user_module and c.eStructuralFeatures else ''}}**kwargs{% endif %}
{%- endmacro %}

Following use case:

class A
  aattr1
  aattr2

class B 
 battr1
 battr2

class C(A,B)


C(aattr1=1, battr1=2)

A.__init__ looks like this def __init__(self, *, aattr1=None, aattr2=None)
This lead to the problem that A.__init__ is called with a keyword argument (battr1) which is not known by the init function.

BR
Andreas

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions