forked from psf/requests
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix HttpAuthenticationType to add callable (#133)
Add a callable object to the `HttpAuthenticationType` type definition. A type checking error occurs when a callable object is given as the `auth` argument. ![image](https://github.com/jawah/niquests/assets/51289448/a460196f-1a9f-4831-a56d-1a992e85da30) <details> <summary>Reproduction code</summary> ```python import niquests def pizza_auth(request: niquests.PreparedRequest) -> niquests.PreparedRequest: if request.headers: request.headers["X-Pizza"] = "Token" return request def test_callable_auth(): r = niquests.get("https://httpbin.org/get", auth=pizza_auth) print(r.json()["headers"]) if __name__ == "__main__": test_callable_auth() ``` </details> This is allowed at runtime. https://github.com/jawah/niquests/blob/d83ab6b98e317bbf82ea950a693fce1fc95936a3/src/niquests/models.py#L615-L647 --------- Co-authored-by: Ahmed TAHRI <ahmed.tahri@cloudnursery.dev>
- Loading branch information
Showing
3 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters