Skip to content

Conversation

@Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Apr 7, 2023

So - This was part of a problem I was having, where I wasn't getting a fully serialized version of the object.

But there is a rather large secondary problem with the new dict approach. the keys don't match up. i.e. "geoName" != "geo_name" for HomeData. This is a problem that will reoccur a lot.

Not sure the best approach, I can put some thought into it tomorrow unless you have any ideas

@Lash-L
Copy link
Collaborator Author

Lash-L commented Apr 7, 2023

@humbertogontijo my thoughts for a fix:

Anywhere the variable is different in python vs their rest calls, we can add a secondary variable to the data class. This one will also be optional, but then we use post init in data class and we check if the pythonic variable is empty, set it = the rest variable.

Will be slower - but should fix our problem

What are your thoughts?

@humbertogontijo
Copy link
Collaborator

Dataclasses have as_dict function. Shouldn't we use that?

@Lash-L
Copy link
Collaborator Author

Lash-L commented Apr 7, 2023

Well as_dict doesn't solve our problem because the keys are different in python vs the api, right?

the api returns "geoNames" whereas python naming is geo_names.

so because geoNames != geo_names, running as_dict or from_dict will result in losing the value.

Am I making sense?

@humbertogontijo
Copy link
Collaborator

Hmm, thats true

@humbertogontijo
Copy link
Collaborator

Fixed in bf52b44

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.

2 participants