robshakir / pyangbind

A plugin for pyang that creates Python bindings for a YANG model.
Other
204 stars 121 forks source link

No way to distinguish between having a default of "False" and having no default #260

Closed andrew-lee-1089 closed 8 months ago

andrew-lee-1089 commented 5 years ago

Due to https://github.com/robshakir/pyangbind/blob/master/pyangbind/lib/yangtypes.py#L939 there is no way to distinguish between leaves that have a default value of False and those that have no default

NickRenton commented 4 years ago

I have found the place of this error in serialize.py

        elif with_defaults == WithDefaults.IF_SET:
          if element._changed() or element._default == element:
            d[yname] = element

In my case, parameter has no a default value (so _default returns False), and type of parameter is int (element is not set and because of its type YANG model returns 0). So 'element._default == element' returns True because of False == 0 is True and in JSON I have a lot of unnecessary integer parameters with value 0

JoseIgnacioTamayo commented 1 year ago

Hi,

Could you please try again with recent versions of pyangbind?

Thanks.

JoseIgnacioTamayo commented 8 months ago

Closing issues without recent activity