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
Remove default empty list #92
Conversation
I'll modify it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request.
Replace []
and {}
with None
in default values
LGTM🙇♂️
Replace Mapping
with Dict
This is aiohttp specification.
It works in Mapping format instead of Dict. I don't think there is any need to change it.
import asyncio
import pybotters
async def main():
async with pybotters.Client() as client:
async with client.get(
"https://httpbin.org/get",
# params={"foo": "bar"},
params=[("foo", "bar")],
) as resp:
data = await resp.text()
print(data)
asyncio.run(main())
Typing generics with standard collections (PEP 585)
Python 3.7 ~ 3.8 requires from __future__ import annotations
, so pytest is failing.
https://www.python.org/dev/peps/pep-0585/#implementation
I want to use the typing module according to the aiohttp source code, should this use the standard collection?
Thanks for the review.
Plus, I rebased commits and unintentionally be tracked authorship for previous commits(not related with me). Squash my commits at your ease when merging. |
43220f6
to
6eae0b2
Compare
** Please change the target branch to |
e42c9f1
to
b5c7c86
Compare
f03543c
to
6eaa4d1
Compare
6503d63
to
248bd52
Compare
* replace Dict with Mapping
248bd52
to
3d83eaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM🥳
Thanks for the contribution!
Replace
[]
and{}
withNone
in default valuesMutable variables such as
[]
and{}
in default values may have some side effects and cause unintended results.In the second section of 8.7 in the Python Language Reference, it is said that use
None
as the default.https://docs.python.org/3/reference/compound_stmts.html#function-definitions
An easier explanation is in the following page:
https://nikos7am.com/posts/mutable-default-arguments/
With replacing empty collections with
None
, those typing are modified toOptional
.Replace
Mapping
withDict
Dict
withMapping
There are some typing incompatibility between
Mapping
andDict
.mypy
reports those errors.Actually,
Mapping
is different fromDict
. However, assuming the usage in the tests, the suitable type isDict
Mapping
.Typing generics with standard collections (PEP 585)
Since the Python 3.9, the standard collections
tuple
,list
anddict
can be used as generics instead ofTuple
,List
andDict
and PEP 585 aims to remove thesetyping
modules.Although the supporting versions include 3.7~3.8, those variables are used as the specific standard collections rather than generics so that this modification won't have side effects also for those versions.
https://www.python.org/dev/peps/pep-0585/
poetry run pytest
)70 passed, 9 warnings
poetry run mypy .
)127 errors
->122 errors
withmypy
0.910