Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Js runs #187

Merged
merged 26 commits into from
Apr 30, 2024
Merged

Js runs #187

merged 26 commits into from
Apr 30, 2024

Conversation

jmmshn
Copy link
Collaborator

@jmmshn jmmshn commented Apr 30, 2024

[BUGFIX] Serialization bug

user_charges is not respected after deserialization.

Monty's as_dict and from_dict do not read the parents __init__ so passing kwargs up does not work.

We have to explicitly pass the parameters down:

from monty.json import MSONable

class A(MSONable):
    def __init__(self, v1 = 1):
        self.v1 = v1
        
class B(A):
    def __init__(self, v2, **kwargs):
        self.v2 = v2
        super().__init__(**kwargs)
        
b = B(v2=2)
print(b.as_dict()) # does not contain v1

A nicer solution will be to fix the behavior in Monty and combine arguments from the full __mro__

Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.90%. Comparing base (c788e64) to head (9c3a1bd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #187   +/-   ##
=======================================
  Coverage   90.90%   90.90%           
=======================================
  Files          11       11           
  Lines        2111     2111           
  Branches      393      393           
=======================================
  Hits         1919     1919           
  Misses        111      111           
  Partials       81       81           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmmshn jmmshn merged commit 22867f7 into main Apr 30, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant