The print statements in parse_response in base spec is executed on every successful request. This creates really noisy output and makes it harder to debug/follow user land code. This is especially difficult when dealing with big objects:
@staticmethod
def parse_response(response: Response, model: BaseModel) -> PythonikResponse:
"""
Return an ErrorResponse object if the response error code is >=400, an instance of "model", or the status code
"""
# try to populate the model
if response.ok:
print(response.text)
if model:
data = response.json()
model = model.model_validate(data)
# else we just let the dev decide what to do
# can call resp.raise_for_status
return PythonikResponse(response=response, data=model)
Similarly, the print statement in base send_request is also noisy
def send_request(self, method, path, **kwargs) -> Response:
"""
Send an http request to a particular URL with a particular method and arguments
"""
url = self.gen_url(path)
print(url)
request = Request(
method=method, url=url, headers=self.session.headers, **kwargs
)
prepped_request = self.session.prepare_request(request)
response = self.session.send(prepped_request, timeout=self.timeout)
return response
The print statements in
parse_responsein base spec is executed on every successful request. This creates really noisy output and makes it harder to debug/follow user land code. This is especially difficult when dealing with big objects:Similarly, the print statement in base
send_requestis also noisy