aio-libs / aio-libs/aiohttp

Typings aren't generic enough when using `response_class`

Open
#7,109 18 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
16.5k
Forks
2.4k
Avg merge
17h 22m
Merged PRs (30d)
212

Description

### Describe the bug

The `ClientSession` class allows you to specify a `response_class` which is then used for responses in place of `ClientResponse` when handling responses. However the typings are not generic, they are hard coded to use `ClientResponse` so custom aspects of the `response_class` result in type errors.

### To Reproduce

1. Add a custom `response_class`
2. Use a request method on a `ClientSession`, e.g. `client.post()`
3. The `response_class` in 1 will be used, but it will still be typed as the default `ClientResponse`

### Expected behavior

Use the `response_class` type in typings.

### Versions

```console
python=3.10.8
aiohttp=3.8.3
```

### Code of Conduct

- [X] I agree to follow the aio-libs Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.