ross / requests-futures

Asynchronous Python HTTP Requests for Humans using Futures
Other
2.11k stars 152 forks source link

Add type annotations #123

Closed benbariteau closed 2 years ago

ross commented 2 years ago

requests itself doesn't currently use type annotations so i'm hesitant to try to do anything with them here. Beyond that if you look at the code the majority of the methods are just wrappers around requests methods that add on async handling. I can't really put types on parameters that don't exist:

https://github.com/ross/requests-futures/blob/a0826c96b017b0bea3125259d451c7b858994d81/requests_futures/sessions.py#L126-L134

Closing for now. If at some point requests makes the changes this can be revisited.

benbariteau commented 2 years ago

That's a good point, but there is a stubs package (types-requests) for it. I think fitting in with that might make sense.

ross commented 2 years ago

Yeah. The types for requests-futures would basically be identical params and the return would change to be a future who's result is the original return type. The whole design of the package is fundamentally set up to preserve the API with the and wrap the return in a future. The types-requests module could be updated to include type info for futures pretty easily if someone wanted to do that.

nambrosini17 commented 1 year ago

The types-requests module could be updated to include type info for futures pretty easily if someone wanted to do that.

How would that work?