Skip to content

Commit cd25fdc

Browse files
authored
Merge pull request #199 from natekspencer/dev
Fix mypy errors
2 parents 465e51b + 5cfc850 commit cd25fdc

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

vivintpy/entity.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
from __future__ import annotations
44

5-
import logging
65
from collections.abc import Callable
76

8-
_LOGGER = logging.getLogger(__name__)
9-
107
UPDATE = "update"
118

129

@@ -34,7 +31,6 @@ def update_data(self, new_val: dict, override: bool = False) -> None:
3431

3532
def handle_pubnub_message(self, message: dict) -> None:
3633
"""Handle a pubnub message directed to this entity."""
37-
_LOGGER.debug("Message received by %s: %s", self.name, message)
3834
self.update_data(message)
3935

4036
def on( # pylint: disable=invalid-name

vivintpy/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def generate_code_challenge() -> tuple[str, str]:
5555
code_verifier = base64.urlsafe_b64encode(os.urandom(40)).decode("utf-8")
5656
code_verifier = re.sub("[^a-zA-Z0-9]+", "", code_verifier)
5757

58-
code_challenge = hashlib.sha256(code_verifier.encode("utf-8")).digest()
59-
code_challenge = base64.urlsafe_b64encode(code_challenge).decode("utf-8")
58+
code_hash = hashlib.sha256(code_verifier.encode("utf-8")).digest()
59+
code_challenge = base64.urlsafe_b64encode(code_hash).decode("utf-8")
6060
code_challenge = code_challenge.replace("=", "")
6161

6262
return (code_verifier, code_challenge)

vivintpy/vivintskyapi.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def is_session_valid(self) -> bool:
7777
async def connect(self) -> dict:
7878
"""Connect to VivintSky Cloud Service."""
7979
if not (self.__has_custom_client_session and self.is_session_valid()):
80+
assert self.__password
8081
await self.__get_vivintsky_session(self.__username, self.__password)
8182
authuser_data = await self.get_authuser_data()
8283
if not authuser_data:
@@ -91,7 +92,7 @@ async def disconnect(self) -> None:
9192
async def verify_mfa(self, code: str) -> None:
9293
"""Verify multi-factor authentication code."""
9394
self.__mfa_pending = False
94-
endpoint = f"{AUTH_ENDPOINT}/idp/api/{"validate" if self.__mfa_type == "code" else "submit"}"
95+
endpoint = f'{AUTH_ENDPOINT}/idp/api/{"validate" if self.__mfa_type == "code" else "submit"}'
9596
resp = await self.__post(
9697
endpoint,
9798
params={"client_id": "ios"},
@@ -105,6 +106,7 @@ async def verify_mfa(self, code: str) -> None:
105106
)
106107
if resp and "url" in resp:
107108
resp = await self.__get(path=f"{AUTH_ENDPOINT}{resp['url']}")
109+
assert resp
108110

109111
if "location" in resp:
110112
query = urllib.parse.urlparse(resp["location"]).query
@@ -501,6 +503,7 @@ async def __get_vivintsky_session(self, username: str, password: str) -> None:
501503
},
502504
allow_redirects=False,
503505
)
506+
assert resp
504507

505508
if "location" in resp and redirect_uri in resp["location"]:
506509
query = urllib.parse.urlparse(resp["location"]).query
@@ -517,6 +520,7 @@ async def __get_vivintsky_session(self, username: str, password: str) -> None:
517520
},
518521
data=json.dumps({"username": username, "password": password}),
519522
)
523+
assert resp
520524

521525
# Check for TOTP/MFA requirement
522526
if "validate" in resp:
@@ -648,6 +652,7 @@ async def _send_grpc(
648652
) -> None:
649653
"""Send gRPC."""
650654
assert self.is_session_valid()
655+
assert self.__token
651656
creds = grpc.ssl_channel_credentials()
652657

653658
async with grpc.aio.secure_channel(GRPC_ENDPOINT, credentials=creds) as channel:

0 commit comments

Comments
 (0)