Skip to content

Conversation

@wbolster
Copy link
Contributor

@wbolster wbolster commented Dec 5, 2017

The URL constructor and the .replace() method now sensibly handle
dictionaries passed to the ‘query’ argument, instead of strictly
requiring it to be an iterable of (key, value) pairs (both of which
must be strings).

Examples:

  URL(query={"foo": "bar"})
  url.replace(query={"foo": "bar"})

This simplifies the API for the common use case, in which:

  • the order of the items does not matter
    (though Python >= 3.6 preserves dictionary order)
  • no duplicate parameters are present

Updated the docs to include an example of this.

Fixes #50.

@codecov-io
Copy link

codecov-io commented Dec 5, 2017

Codecov Report

Merging #53 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
+ Coverage   97.73%   97.75%   +0.02%     
==========================================
  Files           6        6              
  Lines        1105     1116      +11     
  Branches      134      135       +1     
==========================================
+ Hits         1080     1091      +11     
  Misses         13       13              
  Partials       12       12
Impacted Files Coverage Δ
hyperlink/test/test_url.py 99.79% <100%> (ø) ⬆️
hyperlink/_url.py 95.65% <100%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 272d801...45ca800. Read the comment docs.

The URL constructor and the .replace() method now sensibly handle
dictionaries passed to the ‘query’ argument, instead of strictly
requiring it to be an iterable of (key, value) pairs (both of which
must be strings).

Examples:

  URL(query={"foo": "bar"})
  url.replace(query={"foo": "bar"})

This simplifies the API for the common use case, in which:

- the order of the items does not matter
  (though Python >= 3.6 preserves dictionary order)
- no duplicate parameters are present

Updated the docs to include an example of this.

Fixes #50.
@mahmoud mahmoud self-requested a review December 12, 2017 18:09
Copy link
Member

@mahmoud mahmoud left a comment

Choose a reason for hiding this comment

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

LGTM. I think there's a bit of extra docstring under replace but I'll handle that. Thanks so much!

@mahmoud mahmoud merged commit 40ea9e6 into python-hyper:master Dec 12, 2017
@wbolster
Copy link
Contributor Author

you're welcome!

not sure what you're referring to re. the docstring, but now that i look at the docstring lines touched in this pr, the "tuple" type definition was never correct since other types worked as well, and now that's even more flexible with transparent dict handling.

@wbolster wbolster deleted the accept-query-as-dict branch December 13, 2017 11:15
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.

3 participants