Skip to content

Print statements in base spec creates noisy output #33

Description

@nsa-prince

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions