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

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

merged 1 commit into from
Dec 21, 2021

Conversation

asottile
Copy link
Contributor

resolves #6009

I opted to change safe to _Str (which is str | bytes) since that more closely matches the default parameter. for quote_via I changed the first parameter to AnyStr to match the overloaded quote_* functions

@github-actions
Copy link
Contributor

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

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

@JelleZijlstra JelleZijlstra merged commit 60f2d2f into python:master Dec 21, 2021
@asottile asottile deleted the correct-urlencode branch December 21, 2021 02:34
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.

Possible incorrect type annotation in stdlib/urllib/parse.pyi
3 participants
0