psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52k stars 9.29k forks source link

Merge types-requests into psf/requests with py.typed marker #6211

Open kkirsche opened 2 years ago

kkirsche commented 2 years ago

This issue is to merge the existing type hints available in typeshed (here) into this repository.

Currently, psf/requests supports only Python 3.7+ per https://github.com/psf/requests/blob/main/setup.py#L10

As a result, type-related code would not impact usability by end users. Performance concerns related to additional imports may also be addressed by protecting the type-only imports under the typing.TYPE_CHECKING boolean and using the correct syntax downstream.

By making this change, it will keep type information paired with the code, ensuring they get updated together, it will reduce the maintenance burden on the typeshed team (not requested, just a side effect), and will enable more users to get type-hint related information without having to install separate packages.

Depending on your point of view on type hints, they also can reduce the risk of bugs caused by refactoring.

nateprewitt commented 2 years ago

Hi @kkirsche,

We've looked at doing this before. There are a number of issues with the existing typeshed hints we found during our last review. We have a feature branch looking at getting some level of typing integrated in the future but there is currently no timeline for this.

kkirsche commented 2 years ago

Understandable. Some aspects will certainly depend on your philosophies about type hints (e.g. functionally won't crash vs. expected usage) and there are some weird oddities about semantic meanings in a type checker with types like Any vs. object that weren't clear to me before starting to contribute more type hints.

Let me know if there's anything you need support on for that goal :)