mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-30 03:42:51 +08:00
Simplify and fix urllib.parse.urlencode() (#13815)
Remove overloads and type vars. Introduce a protocol for the `quote_via` argument. This means that the interface accepted by the supplied `quote_via` is stricter, and is not dependent on the actual supplied types in the `query` argument, but must work with all possible query types.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from urllib.parse import quote, quote_plus, urlencode
|
||||
|
||||
urlencode({"a": "b"}, quote_via=quote)
|
||||
urlencode({b"a": b"b"}, quote_via=quote)
|
||||
urlencode({"a": b"b"}, quote_via=quote)
|
||||
urlencode({b"a": "b"}, quote_via=quote)
|
||||
mixed_dict: dict[str | bytes, str | bytes] = {}
|
||||
urlencode(mixed_dict, quote_via=quote)
|
||||
|
||||
urlencode({"a": "b"}, quote_via=quote_plus)
|
||||
Reference in New Issue
Block a user