8000 improve urlencode(...) annotation for quote_via by asottile · Pull Request #6345 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

improve urlencode(...) annotation for quote_via #6345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/urllib/parse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def urldefrag(url: bytes | None) -> DefragResultBytes: ...
def urlencode(
query: Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]],
doseq: bool = ...,
safe: AnyStr = ...,
safe: _Str = ...,
encoding: str = ...,
errors: str = ...,
quote_via: Callable[[str, AnyStr, str, str], str] = ...,
quote_via: Callable[[AnyStr, _Str, str, str], str] = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

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

AnyStr has no meaning here, as there is only one instance. Depending on the exact composition of query, quote_via() is called with two or four arguments. If it's called with four arguments, the first argument is a str. I believe that using str is fine, until we improve quote_via to also accept a two argument form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does have some meaning as without it the overloaded function doesn't match the Callable

) -> str: ...
def urljoin(base: AnyStr, url: AnyStr | None, allow_fragments: bool = ...) -> AnyStr: ...
@overload
Expand Down
0