Skip to content

Conversation

liffiton
Copy link
Contributor

From the function docstring: "The body argument may be a dict, a list of 2-tuples, or a formencoded string."

liffiton and others added 2 commits June 17, 2025 09:36
From the oauthlib documentation: "The body argument may be a dict, a list of 2-tuples, or a formencoded string."
@liffiton liffiton changed the title Fix type on body argument of oauthlib.oauth1.Client.sign() [oauthlib] Fix type on body argument of oauthlib.oauth1.Client.sign() Jun 17, 2025

This comment has been minimized.

@liffiton liffiton marked this pull request as ready for review June 17, 2025 15:14
liffiton added a commit to liffiton/Gen-Ed that referenced this pull request Jun 17, 2025
One mypy type error remains, caused by an issue in the typeshed type stubs.
python/typeshed#14295
Comment on lines 59 to 66
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,
): ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these arguments are forwarded to oauthlib.common.Request: https://github.com/oauthlib/oauthlib/blob/v3.3.0/oauthlib/oauth1/rfc5849/__init__.py#L295-L296. If you're feeling ambitious, you could align some of the other parameter hints with its signature:

def __init__(
self,
uri: str,
http_method: _HTTPMethod = "GET",
body: str | dict[str, str] | list[tuple[str, str]] | None = None,
headers: Mapping[str, str] | None = None,
encoding: str = "utf-8",
): ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Thanks for the suggestion.

def sign(
self,
uri,
http_method: str = "GET",

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks. I don't have experience with type stubs, so I appreciate you providing the import statement.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and sorry for the delay!

@srittau srittau merged commit dd6d7bf into python:main Jul 7, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants