Skip to content

use a dictionary for query params #50

@wbolster

Description

@wbolster

hyperlink does not support dictionaries for query. while i know that technically this is an orderedmultidict, this is just not nice from an api perspective:

>>> url = URL.from_text('https://example.org/api/v2')

>>> url.replace(query={'foo': 'bar'})
[...]
ValueError: too many values to unpack (expected 2)

instead, this works:

>>> url.replace(query=[('foo', 'bar')])
URL.from_text('https://example.org/api/v2?foo=bar')

or using .items():

>>> url.replace(query={'foo': 'bar'}.items())
URL.from_text('https://example.org/api/v2?foo=bar')

but tbh none of this looks appealing to me. :)

any reason for the current behaviour?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions