microsoft / microsoft/typespec

[python] Add new flags "http-stack" and "async-http-stack"

Open
#5,777 0 comments 0 reactions 1 assignee Claimed by @iscai-msft View on GitHub
emitter:client:python
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

transferred from https://github.com/Azure/autorest.python/issues/2246

`corehttp` will not install any HTTP stack by default, and will require one installed by the SDK itself.

This issue is to add a flag that with those values:
- `http-stack`:
- `requests`
- `httpx`
- `async-http-stack`:
- `aiohttp`
- `httpx`

Default behavior if no flag is `requests` and `aiohttp`

Once this flag is set, we need to generate different code:
- We provide `extra_requires` to make this experience easier. Change setup.py accordingly to `corehttp[requests]` or `corehttp[httpx]` or the combined version `corehttp[requests, httpx]`
- Create the right transport in client constructor code to create a `transport` of the right type, and pass it to the `PipelineClient` (resp. `AsyncPipelineClient`. Beware to pop customer 'transport' kwarg as well. Also, the import needs to be inside the constructor, the import is not done if the `transport` kwarg is set. For instance:

```python
# Pseudo-code,
transport = kwargs.pop("transport", None)
if not transport:
from corehttp.transport.httpx import HttpxTransport
transport = HttpxTransport(**kwargs)
```

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.