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

Support Sequence[Tuple[str, str]] type when setting cookies. #1209

Closed
tomchristie opened this issue Aug 21, 2020 · 2 comments
Closed

Support Sequence[Tuple[str, str]] type when setting cookies. #1209

tomchristie opened this issue Aug 21, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@tomchristie
Copy link
Member

For consistency, we should support styles like: cookies=[('name', 'value')].

We allow either dicts or lists-of-tuples for each of data, files, params & headers, so it makes sense for us to do it here too.

@tomchristie tomchristie added enhancement New feature or request good first issue Good for newcomers labels Aug 21, 2020
@tomchristie
Copy link
Member Author

We'd want to adjust the __init__ to handle that case properly...

if cookies is None or isinstance(cookies, dict):

And adjust the type signature...

CookieTypes = Union["Cookies", CookieJar, Dict[str, str]]

Plus add a test case for it in here... https://github.com/encode/httpx/blob/master/tests/models/test_cookies.py
I guess use something like this...

cookies = httpx.Cookies([("key1", "value1"), ("key2", "value2")])
# followed by some appropriate assertions, similar to those in `test_cookies`.

Ideally do this in two commits - first add the (failing) test case, and then add the fixes.

cdeler added a commit to cdeler/httpx that referenced this issue Aug 21, 2020
cdeler added a commit to cdeler/httpx that referenced this issue Aug 21, 2020
tomchristie pushed a commit that referenced this issue Aug 24, 2020
* Added test which checks that cookie might be built from a list of tuples (#1209)

* Made cookies constructable from a list of tuples (#1209)
@tomchristie
Copy link
Member Author

Closed via #1211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant