From 94ae98f61e539df55ee2e308d8c5db339774be50 Mon Sep 17 00:00:00 2001 From: Mark Liffiton Date: Tue, 17 Jun 2025 09:36:18 -0500 Subject: [PATCH 1/4] Fix type on body argument of oauth1.Client.sign() From the oauthlib documentation: "The body argument may be a dict, a list of 2-tuples, or a formencoded string." --- stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi index 6730205943f7..606fb8ff981e 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi @@ -56,4 +56,4 @@ class Client: ): ... def get_oauth_signature(self, request): ... def get_oauth_params(self, request): ... - def sign(self, uri, http_method: str = "GET", body: str | None = None, headers: dict[str, str] | None = None, realm=None): ... + def sign(self, uri, http_method: str = "GET", body: str | dict[str, str] | list[tuple[str, str]] | None = None, headers: dict[str, str] | None = None, realm=None): ... From a6e8e23dc043dc0636c949a8306b25c9fa9ba238 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 14:39:56 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi index 606fb8ff981e..c5d9d5ef142d 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi @@ -56,4 +56,11 @@ class Client: ): ... def get_oauth_signature(self, request): ... def get_oauth_params(self, request): ... - def sign(self, uri, http_method: str = "GET", body: str | dict[str, str] | list[tuple[str, str]] | None = None, headers: dict[str, str] | None = None, realm=None): ... + def sign( + self, + uri, + http_method: str = "GET", + body: str | dict[str, str] | list[tuple[str, str]] | None = None, + headers: dict[str, str] | None = None, + realm=None, + ): ... From 98c0ebaf300ad158fe9abc9b730bafe8bb448d73 Mon Sep 17 00:00:00 2001 From: Mark Liffiton Date: Thu, 19 Jun 2025 22:47:37 -0500 Subject: [PATCH 3/4] Add further types as suggested in PR review comments. --- stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi index c5d9d5ef142d..52962cb00871 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi @@ -3,6 +3,8 @@ from collections.abc import Callable from logging import Logger from typing import Any, Final +from oauthlib.common import _HTTPMethod + log: Logger SIGNATURE_HMAC_SHA1: Final[str] SIGNATURE_HMAC_SHA256: Final[str] @@ -58,9 +60,9 @@ class Client: def get_oauth_params(self, request): ... def sign( self, - uri, - http_method: str = "GET", + uri: str, + http_method: _HTTPMethod = "GET", body: str | dict[str, str] | list[tuple[str, str]] | None = None, - headers: dict[str, str] | None = None, + headers: Mapping[str, str] | None = None, realm=None, ): ... From 57d152df16f683114fbdee8c9760b17fcc22729c Mon Sep 17 00:00:00 2001 From: Mark Liffiton Date: Thu, 19 Jun 2025 22:48:55 -0500 Subject: [PATCH 4/4] Add missing import --- stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi index 52962cb00871..a909c15b1d78 100644 --- a/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi +++ b/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Mapping from logging import Logger from typing import Any, Final