Skip to content
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

Type annotations and implementation mismatch #540

Closed
nikitagashkov opened this issue Oct 23, 2020 · 2 comments
Closed

Type annotations and implementation mismatch #540

nikitagashkov opened this issue Oct 23, 2020 · 2 comments
Labels

Comments

@nikitagashkov
Copy link

🐞 Describe the bug
Judging by yarl.URL type annotations, it is required to pass only integers or strings as query string values and lists are prohibited. But, actually, yarl correctly handles the provided list of integers or strings as a query string value.

💡 To Reproduce
The mismatch can be observed on the following snippet of code:

import yarl
print(yarl.URL("http://localhost:8000").with_query(params=[1, 2, 3]).human_repr())
  1. Run the given code snippet and observe correct handling of a list of params:
$ python test.py
http://localhost:8000/?params=1&params=2&params=3
  1. Run the mypy against the given code snippet and observe mypys complaints:
$ mypy test.py
test.py:6: error: No overload variant of "with_query" of "URL" matches argument type "List[int]"
test.py:6: note: Possible overload variant:
test.py:6: note:     def with_query(self, **kwargs: Union[str, int]) -> URL
test.py:6: note:     <1 more non-matching overload not shown>
Found 1 error in 1 file (checked 1 source file)

💡 Expected behavior
No type errors when providing list of query parameters.

📋 Logs/tracebacks

📋 Your version of the Python

$ python --version
Python 3.8.6

📋 Your version of the aiohttp/yarl/multidict distributions

$ python -m pip show aiohttp                                                                                                                                                                                                                                                                                              0
Name: aiohttp
Version: 3.6.3
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: [email protected]
License: Apache 2
Location: ...
Requires: multidict, yarl, attrs, async-timeout, chardet
Required-by: test
$ python -m pip show multidict
Name: multidict
Version: 4.7.6
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: ...
Requires:
Required-by: yarl, aiohttp
$ python -m pip show yarl
Name: yarl
Version: 1.5.1
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: ...
Requires: idna, multidict
Required-by: test, aiohttp

📋 Additional context

@asvetlov
Copy link
Member

Pull request is welcome!

@nikitagashkov
Copy link
Author

NVM, as it turns out, the fix has already landed on master (#529) :) It just hasn't been pushed to PyPI yet.

Closing this as a duplicate of #528.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants