You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has been bugging me for a while but can you include the raw json data in the returned pydantic model? Sometimes the assumption that you used to parse the json isn't correct, and I would have to hack into the library to get the original json to parse it myself.
Here's an example: The real-time notes API returns 'transformer': {'obtained': True, 'recovery_time': {'Day': 0, 'Hour': 5, 'Minute': 0, 'Second': 0, 'reached': True}, 'wiki': ''}. Mihoyo only returns the biggest time unit. In this case it rounds down to 5 hours so even if its 5 hours and 12 minutes it still returns 5 hours. The remaining_transformer_recovery_time as it's currently implemented gives the wrong impression that it will recover at this exact time. Meanwhile if I have the original json, I can display something like "parametric transformer will recover in 5 hours...", "parametric transformer will recover in 21 minutes..."
This is just one example. I have come across a few cases where the raw json is greatly appreciated, like the fields that you haven't yet added (e.g. data["transformer"]["obtained"])
The text was updated successfully, but these errors were encountered:
I'm all for making patching easier but I'm not sure if this is truly the best approach. Storing raw values should be possible with a root validator in the base class so I can do that but I'd rather allow the user to make their own models if they so wish.
For this specific case I think I should store the time as a timedelta instead of a datetime which should allow for easier usage.
The Transformer will return None if not obtained as opposed to giving 0 remaining time so that's not really a problem.
Thanks! That's great to hear. I like the idea of pretty Python models with pydantic but it can be restricting sometimes. Personally I prefer genshin.py to remain a barebone library or at least expose the basic hoyolab APIs so I can build on other things on it.
The custom model library looks very promising. Can't wait to see it.
This has been bugging me for a while but can you include the raw json data in the returned pydantic model? Sometimes the assumption that you used to parse the json isn't correct, and I would have to hack into the library to get the original json to parse it myself.
Here's an example: The real-time notes API returns
'transformer': {'obtained': True, 'recovery_time': {'Day': 0, 'Hour': 5, 'Minute': 0, 'Second': 0, 'reached': True}, 'wiki': ''}
. Mihoyo only returns the biggest time unit. In this case it rounds down to 5 hours so even if its 5 hours and 12 minutes it still returns 5 hours. Theremaining_transformer_recovery_time
as it's currently implemented gives the wrong impression that it will recover at this exact time. Meanwhile if I have the original json, I can display something like "parametric transformer will recover in 5 hours...", "parametric transformer will recover in 21 minutes..."This is just one example. I have come across a few cases where the raw json is greatly appreciated, like the fields that you haven't yet added (e.g.
data["transformer"]["obtained"]
)The text was updated successfully, but these errors were encountered: