- Notifications
You must be signed in to change notification settings - Fork675
feat: addasdict() andto_json() methods to Gitlab Objects#1872
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
88527fa to2d3dec6Compareas_dict() method to the Gitlab Objectsas_dict() method to the Gitlab Objects2d3dec6 tob0d55eeCompareas_dict() method to the Gitlab Objectsasdict() method to the Gitlab Objectscodecov-commenter commentedFeb 2, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #1872 +/- ##==========================================- Coverage 95.41% 95.39% -0.02%========================================== Files 79 79 Lines 5166 5170 +4 ==========================================+ Hits 4929 4932 +3- Misses 237 238 +1
Flags with carried forward coverage won't be shown.Click here to find out more.
|
b0d55ee to0975678Comparenejch commentedFeb 2, 2022
The more I compare this to What if we add a method like I think this would make the example in the issue quite pretty as well: withopen('data.txt','w')asf:f.write(src_prj.labels.list(all=True)[0].to_json()) |
nejch commentedFeb 2, 2022
Going back again, seems like the library supported both json and dict method for v3 with a custom encoder back in 2017. So maybe we could just re-add both: Lines 525 to 536 in7011694
|
f2ed5e5 tof229f7fCompareJohnVillalovos commentedFeb 2, 2022
Sounds good to me. I've got |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
f229f7f to03d9977Compare4a64a56 to973e68fCompareasdict() method to the Gitlab Objectsasdict() andto_json() methods to Gitlab Objectsef5aed2 toec643b7Comparemax-wittig commentedJul 12, 2022
Very cool! |
ec643b7 toa636938ComparePreviously the `attributes` method would show the original values in aGitlab Object even if they had been updated. Correct this so that theupdated value will be returned.Also use copy.deepcopy() to ensure that modifying the dictionary returned cannot also modify the object.
Add an `asdict()` method that returns a dictionary representation copyof the Gitlab Object. This is a copy and changes made to it will haveno impact on the Gitlab Object.The `asdict()` method name was chosen as both the `dataclasses` and`attrs` libraries have an `asdict()` function which has the similarpurpose of creating a dictionary represenation of an object.Also add a `to_json()` method that returns a JSON stringrepresentation of the object.Closes:#1116
a636938 to08ac071Compare
Uh oh!
There was an error while loading.Please reload this page.
Add an
asdict()method that returns a dictionary representation copyof the Gitlab Object. This is a copy and changes made to it will have
no impact on the Gitlab Object.
The
asdict()method name was chosen as both thedataclassesandattrslibraries have anasdict()function which has the similarpurpose of creating a dictionary represenation of an object.
Also add a
to_json()method that returns a JSON stringrepresentation of the object.
Closes:#1116