Azure / Azure/azure-sdk-for-python

Inline typing for Requests

Offen
#46,705 0 Kommentare 1 Reaktion 1 zugewiesene Person Beansprucht von @kashifkhan Auf GitHub ansehen
Azure.Core
Vorherrschende Sprache
Python
Sterne
5.6k
Forks
3.4k
Ø Merge
2 T. 2 Std.
Gemergte PRs (30 T.)
202

Beschreibung

- **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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.