mewwts / addict

The Python Dict that's better than heroin.
MIT License
2.46k stars 132 forks source link

fix copy and pickle so they work with freezing #137

Open jpn-- opened 3 years ago

jpn-- commented 3 years ago

This PR makes it so frozen Dict's can be copied and pickled. Addresses #136

>>> from addict import Dict
>>> a = Dict().copy()
>>> a.foo.bar
{}
>>> b = Dict(aaa=1, bbb=2)
>>> b.freeze()
>>> b.aaa == 1
True
>>> b.ccc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/addict/addict/addict.py", line 67, in __getattr__
    return self.__getitem__(item)
  File "/addict/addict/addict.py", line 71, in __missing__
    raise KeyError(name)
KeyError: 'ccc'
>>> c = b.copy()
>>> c.ddd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/addict/addict/addict.py", line 67, in __getattr__
    return self.__getitem__(item)
  File "/addict/addict/addict.py", line 71, in __missing__
    raise KeyError(name)
KeyError: 'ddd'
>>> 
coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 03a9506176e7811d33dac2cb492d37336dd5d6ba on jpn--:master into 75284f9593dfb929cadd900aff9e35e7c7aec54b on mewwts:master.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 03a9506176e7811d33dac2cb492d37336dd5d6ba on jpn--:master into 75284f9593dfb929cadd900aff9e35e7c7aec54b on mewwts:master.

schmoelder commented 3 years ago

Is there a reason not to merge? I can confirm that it solves #136

ma-sadeghi commented 1 year ago

Any update on this?