Skip to content

Conversation

@sh1man
Copy link

@sh1man sh1man commented Aug 5, 2025

No description provided.

BYTES = "bytes"
NO_CONTENT = "no_content"

ResponseTypeLiteral = Literal["json", "text", "bytes", "no_content"] No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this literal?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more convenient and faster, we remove one useless import

additional_params: Optional[Dict[str, Any]] = None,
method_class: Optional[Callable[..., BoundMethod]] = None,
send_json: bool = True,
response_type: Optional[ResponseTypeLiteral] = "json",
Copy link
Member

@Tishka17 Tishka17 Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use enum here? anyway I do not see why we should allow None value

    response_type: ResponseType = ResponseType.json,

Copy link
Author

@sh1man sh1man Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, it's more convenient to use a literal. This value is optional and by default it's json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not handle Nine value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

case ResponseType.BYTES:
return await response.read()
case ResponseType.NO_CONTENT:
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we validate content-length here?
I'd rather have 2 cases here:

  • SKIP
  • NO_CONTENT

Copy link
Author

@sh1man sh1man Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. content-length I think validation has a place to be, but shouldn't it be at the HTTP level?
    (I think we should ask the community)
  2. I think it's unnecessary, maybe it will confuse

async def _response_body(self, response: ClientResponse) -> Any:
try:
return await response.json()
match self.response_type:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's avoid match for now, just in case we want to supper older python

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this can be fixed.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants