Skip to content

DictNestedField field wrongly inited #33

@Frankkkkk

Description

@Frankkkkk

Models using DictNestedField fields are wrongly inited and can't be used for writing:

Example (from XXX):

class Score(pykorm.models.Nested):
    exterior: int = pykorm.fields.DataField('exterior')
    delicious: int = pykorm.fields.DataField('delicious', 10)


@pykorm.k8s_custom_object('pykorm.infomaniak.com', 'v1', 'peaches')
class Peach(pykorm.NamespacedModel):
    variety: str = pykorm.fields.Spec('variety', default='default-variety')
    price: str = pykorm.fields.Spec('price', default=1)
    colours: list = pykorm.fields.Spec('colours', default=[])
    score: Score = pykorm.fields.DictNestedField(Score, path=['spec', 'score'])

Results in the following error when writing to p.score.delicious:

>       p.score.exterior = 42
E       AttributeError: 'NoneType' object has no attribute 'exterior'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions