Open baffelli opened 1 year ago
You're suggesting something like the following?
from pydantic import BaseModel
class KeyResponse(BaseModel):
public: str
private: str
response_model = KeyResponse.model_validate(response.content.decode())
pub_key = response_model.public
priv_key = response_model.private
Yes, correct. I think it's a bit safer and slightly more ergonomic
Instead of directly accessing json, you could define a few helper dataclasses or pydantic models:
https://github.com/empa-scientific-it/cscs-keygen/blob/20b8c487deab801ab9d550ba91a00d7f9f06b99d/utils.py#L59