Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address accessing of non-existing field _maybe_parsed_body within httpx.Response object #166

Open
vdusek opened this issue Nov 20, 2023 · 4 comments
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@vdusek
Copy link
Contributor

vdusek commented Nov 20, 2023

It seems that the following code:

response: httpx.Response = await self.http_client.call(
    url=self._url(f'records/{key}'),
    method='GET',
    params=self._params(),
)

returns a response of type httpx.Response. Later the field _maybe_parsed_body is accessed:

return {
    'value': response._maybe_parsed_body,
    '...': '...',
}

There are 2 occurrences of this:

Check if http_client.call really returns a httpx.Response object and in such case fix the accessing of non-existing field _maybe_parsed_body.

@vdusek vdusek added bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team. labels Nov 20, 2023
@vdusek vdusek self-assigned this Nov 20, 2023
@fnesveda
Copy link
Member

http_client.call returns a httpx.Response which is in some cases enhanced with a _maybe_parsed_body. It's a bit of a hack which was really useful when we still used requests, and simplified the code a lot, but when we switched to using httpx and did some more changes, it ended up being used only in one method, when fetching a key-value store record body. So now we could put the "maybe" response parsing into that method, instead of having it in the http_client, to have a better separation of concerns, and less hacks.

@vdusek
Copy link
Contributor Author

vdusek commented Nov 27, 2023

My IDE was not able to recognize that, instead it raised an accessing of non-existing field error. The self.http_client.call is annotated to return httpx.Response object. So it might be the source of the problem.

@fnesveda
Copy link
Member

Yeah, that's probably it. I wonder how this ever passed lint without a #noqa comment 🤷

@vdusek
Copy link
Contributor Author

vdusek commented Nov 27, 2023

Yeah, that's probably it. I wonder how this ever passed lint without a #noqa comment 🤷

I think because accessing fields is checked by Mypy. That's the reason why there is # type: ignore .

@vdusek vdusek removed their assignment Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants