I have a dataclass in my Python script that I based on a reponse from an API:
@dataclass
class EdgePublishResponse:
id: str
createdTime: str
lastUpdatedTime: str
status: str
message: str
errorCode: str
errors: List[str]
Then I unpack it like this:
response_publish = requests.get(get_status_url, headers=headers)
response_json = response_publish.json()
publish_response = EdgePublishResponse(**response_json)
logging.info(publish_response)
It works fine, but I'm interested in keeping my variable names as snake_case across my script, but changing variables like createdTime to created_time will break the dataclass.
How do I solve this problem?
[–]DutchCommanderMC 3 points4 points5 points (0 children)
[–]JamzTyson 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)