Azure / Azure/azure-sdk-for-python

Inline typing for Requests

Aperta
#46,705 0 commenti 1 reazione 1 assegnatario Rivendicata da @kashifkhan Vedi su GitHub
Azure.Core
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g 2h
PR unite (30g)
202

Descrizione

- **Package Name**: azure-core
- **Package Version**: 1.40.0
- **Operating System**: All
- **Python Version**: All

**Describe the bug**
Starting with Requests 2.34.0, typing will be moving from Typeshed to inline types for Requests. Those are largely the same except for some technical corrections, and more complete compound types.

We've been testing downstream projects and most are passing with our pre-release ([2.34.0.dev1](https://pypi.org/project/requests/2.34.0.dev1/)). We're seeing two issues with pyright in the Azure SDK for Python though.

* [sdk/core/corehttp/corehttp/transport/requests/_requests_basic.py#L131-L138](https://github.com/Azure/azure-sdk-for-python/blob/1c4e2bf55a7e9cce381897fed6ed2e8a00f8afe3/sdk/core/corehttp/corehttp/transport/requests/_requests_basic.py#L131-L138)
* [sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py#L322-L356](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py#L322-L356)

Both of these `send` implementations type `proxies` as `MutableMapping[str, str]`. While that matches Typeshed, `.copy()` will be called on input for the proxies parameter. The `MutableMapping` interface doesn't require this, which can lead to runtime failures. The parameter should be typed as `dict[str, str]` to reflect the actual API contract.

**To Reproduce**
Steps to reproduce the behavior:
1. Install the pre-release of Requests (2.34.0.dev1).
2. Run type checking as usual.

**Expected behavior**
The type checkers pass with valid types.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.