mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-11 18:08:02 +00:00
Avoid rebuilding urls for every request (#715)
* Avoid rebuilding urls for every request * more fixes * more fixes * make mypy happy * reduce * tweak * fix tests * fix tests * tweak * tweak * lint * fix type
This commit is contained in:
@@ -3,6 +3,7 @@ import asyncio
|
||||
from typing import Any, Dict, Optional, Tuple, Union
|
||||
|
||||
import aiohttp
|
||||
from yarl import URL
|
||||
|
||||
from .deviceconfig import DeviceConfig
|
||||
from .exceptions import (
|
||||
@@ -25,7 +26,7 @@ class HttpClient:
|
||||
self._config = config
|
||||
self._client_session: aiohttp.ClientSession = None
|
||||
self._jar = aiohttp.CookieJar(unsafe=True, quote_cookie=False)
|
||||
self._last_url = f"http://{self._config.host}/"
|
||||
self._last_url = URL(f"http://{self._config.host}/")
|
||||
|
||||
@property
|
||||
def client(self) -> aiohttp.ClientSession:
|
||||
@@ -41,7 +42,7 @@ class HttpClient:
|
||||
|
||||
async def post(
|
||||
self,
|
||||
url: str,
|
||||
url: URL,
|
||||
*,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
data: Optional[bytes] = None,
|
||||
|
Reference in New Issue
Block a user