cwacek/python-jsonschema-objects

self as property name :(

Closed this issue · 3 comments

Hi,

If a property name is called self, the object cannot be instanciated :s - See example code below

import python_jsonschema_objects as pjs

schema = {
    'properties': {
        'self': {
            'additionalProperties': False,
            'properties': {
                'href': {
                    'type': 'string'
                }
            },
            'required': ['href'],
            'title': 'link_field',
            'type': 'object'
        }
    },
    'required': ['self'],
    'title': 'LinkObject',
    'type': 'object'
}


ns = pjs.ObjectBuilder(schema).build_classes()
link = ns.Linkobject(**{"self": {"href": "Resource/123"}})

This raises the exception during the instanciation of the LinkObject:

TypeError: __init__() got multiple values for argument 'self'

Is this fixable somehow ?

I could imagine to store all attributes in a dict and allow property access through __getattr__. That way all names should be possible for attributes.

Stale issue message