Giter Site home page Giter Site logo

Comments (7)

fabiocaccamo avatar fabiocaccamo commented on May 27, 2024 1

@gschoenberger I'm pretty sure it's related to the new keyattr feature, could you try to disable it?

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on May 27, 2024 1

In the end I enabled it by default: https://github.com/fabiocaccamo/python-benedict#keyattr

The problem you reported has its origins here: https://github.com/fabiocaccamo/python-benedict/blob/main/benedict/dicts/keyattr/keyattr_dict.py#L26

When getting an attribute, if it doesn't exist yet it is set on the fly on the dict for allow chaining on set item operations, eg. my_dict.new_key.another_new_key.x = 1.0

Probably your code tries to call those attrs on the dict, and for the reason above they are created on the fly.

A solution could be to restrict the automatic keys creation only for keys that doesn't start with an _, what do you think? Any suggestion is appreciated.

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on May 27, 2024

@gschoenberger thank you for reporting this.

Any changes related to dumping/loading benedicts to/from JSON?

Not at all.

from python-benedict.

gschoenberger avatar gschoenberger commented on May 27, 2024

@gschoenberger thank you for reporting this.

Any changes related to dumping/loading benedicts to/from JSON?

Not at all.

Mh. We will investigate this further next week and let you know!

from python-benedict.

gschoenberger avatar gschoenberger commented on May 27, 2024

Thanks for the hint, we disabled the keyattr feature and unit tests passed!

def __init__(self, data: Optional[Dict[Any, Any]] = None) -> None:
    self.data = benedict(keyattr_enabled=False) if data is None else benedict(data, keyattr_enabled=False)

Shouldn't it be disabled by default? (according to the README)
By default this feature is disabled due to its implicit limitations: it works only for string keys and only if the keys don't clash with the supported methods names.

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on May 27, 2024

Fixed in 0.29.1.

from python-benedict.

gschoenberger avatar gschoenberger commented on May 27, 2024

Great,, thanks!

from python-benedict.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.