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

Use Query typedef from yarl for params #8564

Merged
merged 18 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
Generic,
Iterable,
List,
Mapping,
Optional,
bdraco marked this conversation as resolved.
Show resolved Hide resolved
Set,
Tuple,
Expand Down Expand Up @@ -96,7 +95,7 @@
from .http_websocket import WSHandshakeError, WSMessage, ws_ext_gen, ws_ext_parse
from .streams import FlowControlDataQueue
from .tracing import Trace, TraceConfig
from .typedefs import JSONEncoder, LooseCookies, LooseHeaders, StrOrURL
from .typedefs import JSONEncoder, LooseCookies, LooseHeaders, Query, StrOrURL

__all__ = (
# client_exceptions
Expand Down Expand Up @@ -155,7 +154,7 @@


class _RequestOptions(TypedDict, total=False):
params: Union[Mapping[str, str], None]
params: Query
data: Any
json: Any
cookies: Union[LooseCookies, None]
Expand Down Expand Up @@ -392,7 +391,7 @@ async def _request(
method: str,
str_or_url: StrOrURL,
*,
params: Optional[Mapping[str, str]] = None,
params: Query = None,
data: Any = None,
json: Any = None,
cookies: Optional[LooseCookies] = None,
Expand Down Expand Up @@ -767,7 +766,7 @@ def ws_connect(
heartbeat: Optional[float] = None,
auth: Optional[BasicAuth] = None,
origin: Optional[str] = None,
params: Optional[Mapping[str, str]] = None,
params: Query = None,
headers: Optional[LooseHeaders] = None,
proxy: Optional[StrOrURL] = None,
proxy_auth: Optional[BasicAuth] = None,
Expand Down Expand Up @@ -815,7 +814,7 @@ async def _ws_connect(
heartbeat: Optional[float] = None,
auth: Optional[BasicAuth] = None,
origin: Optional[str] = None,
params: Optional[Mapping[str, str]] = None,
params: Query = None,
headers: Optional[LooseHeaders] = None,
proxy: Optional[StrOrURL] = None,
proxy_auth: Optional[BasicAuth] = None,
Expand Down Expand Up @@ -1344,7 +1343,7 @@ def request(
method: str,
url: StrOrURL,
*,
params: Optional[Mapping[str, str]] = None,
params: Query = None,
data: Any = None,
json: Any = None,
headers: Optional[LooseHeaders] = None,
Expand Down
3 changes: 2 additions & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
JSONDecoder,
LooseCookies,
LooseHeaders,
Query,
RawHeaders,
)

Expand Down Expand Up @@ -197,7 +198,7 @@ def __init__(
method: str,
url: URL,
*,
params: Optional[Mapping[str, str]] = None,
params: Query = None,
headers: Optional[LooseHeaders] = None,
skip_auto_headers: Iterable[str] = frozenset(),
data: Any = None,
Expand Down
8 changes: 8 additions & 0 deletions aiohttp/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Callable,
Iterable,
Mapping,
Sequence,
Tuple,
Union,
)
Expand Down Expand Up @@ -52,3 +53,10 @@
Middleware = Callable[["Request", Handler], Awaitable["StreamResponse"]]

PathLike = Union[str, "os.PathLike[str]"]

# from yarl https://github.com/aio-libs/yarl/blob/efea830d088309214450b359f0d02792ba2eaa50/yarl/__init__.pyi#L18-L22
SimpleQuery = Union[str, int, float]
QueryVariable = Union[SimpleQuery, Sequence[SimpleQuery]]
Query = Union[
None, str, Mapping[str, QueryVariable], Sequence[Tuple[str, QueryVariable]]
]
Loading