mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 23:30:10 -07:00
Improve type information
Most parameters to Client's __init__ are optional. This matters when adding more types other places.
This commit is contained in:
parent
a72998386c
commit
2641e44f3e
@ -25,7 +25,7 @@ class Monitor(object):
|
||||
makes one `Monitor` object suitable for long-term monitoring.
|
||||
"""
|
||||
|
||||
def __init__(self, session, device_id) -> None:
|
||||
def __init__(self, session: core.Session, device_id: str) -> None:
|
||||
self.session = session
|
||||
self.device_id = device_id
|
||||
|
||||
@ -75,13 +75,16 @@ class Client(object):
|
||||
and allows serialization of state.
|
||||
"""
|
||||
|
||||
def __init__(self, gateway=None, auth=None, session=None,
|
||||
def __init__(self,
|
||||
gateway: Optional[core.Gateway] = None,
|
||||
auth: Optional[core.Auth] = None,
|
||||
session: Optional[core.Session] = None,
|
||||
country: str = DEFAULT_COUNTRY,
|
||||
language: str = DEFAULT_LANGUAGE) -> None:
|
||||
# The three steps required to get access to call the API.
|
||||
self._gateway: core.Gateway = gateway
|
||||
self._auth: core.Auth = auth
|
||||
self._session: core.Session = session
|
||||
self._gateway: Optional[core.Gateway] = gateway
|
||||
self._auth: Optional[core.Auth] = auth
|
||||
self._session: Optional[core.Session] = session
|
||||
|
||||
# The last list of devices we got from the server. This is the
|
||||
# raw JSON list data describing the devices.
|
||||
|
@ -7,7 +7,7 @@ import hashlib
|
||||
import hmac
|
||||
import datetime
|
||||
import requests
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
GATEWAY_URL = 'https://kic.lgthinq.com:46030/api/common/gatewayUriList'
|
||||
APP_KEY = 'wideq'
|
||||
@ -252,7 +252,7 @@ class Gateway(object):
|
||||
self.language = language
|
||||
|
||||
@classmethod
|
||||
def discover(cls, country, language):
|
||||
def discover(cls, country, language) -> 'Gateway':
|
||||
gw = gateway_info(country, language)
|
||||
return cls(gw['empUri'], gw['thinqUri'], gw['oauthUri'],
|
||||
country, language)
|
||||
@ -275,7 +275,7 @@ class Auth(object):
|
||||
access_token, refresh_token = parse_oauth_callback(url)
|
||||
return cls(gateway, access_token, refresh_token)
|
||||
|
||||
def start_session(self):
|
||||
def start_session(self) -> Tuple['Session', List[Dict[str, Any]]]:
|
||||
"""Start an API session for the logged-in user. Return the
|
||||
Session object and a list of the user's devices.
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user