Skip to content

Commit

Permalink
fix(module): use correct return type for user_id()
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Aug 27, 2024
1 parent 3a85606 commit e8bead4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pytouchlinesl"
version = "0.1.4"
version = "0.1.5"
authors = [{ name = "Jon Seager", email = "[email protected]" }]
description = "An API client for Roth's TouchlineSL control system."
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion pytouchlinesl/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BaseClient(ABC):
"""Base API client implementation for Roth API clients."""

@abstractmethod
async def user_id(self) -> str:
async def user_id(self) -> int:
"""Return the unique user id for the authenticated account."""
pass

Expand Down
4 changes: 2 additions & 2 deletions pytouchlinesl/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ async def _login(self):
self._user_id = resp.get("user_id")
self._token = resp.get("token")

async def user_id(self) -> str:
async def user_id(self) -> int:
"""Return the unique user id for the authenticated account."""
if self._token is None:
await self._login()

assert isinstance(self._user_id, str)
assert isinstance(self._user_id, int)
return self._user_id

async def authenticated(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pytouchlinesl/touchlinesl.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
raise TypeError("username and password must be strings if no client is provided")
self._client = RothAPI(username=username, password=password)

async def user_id(self) -> str:
async def user_id(self) -> int:
"""Return the unique user ID of the authenticated account."""
return await self._client.user_id()

Expand Down
4 changes: 2 additions & 2 deletions tests/fake_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

class FakeRothAPI(BaseClient):
def __init__(self):
self._user_id = "123456789"
self._user_id = 123456789
self._token = "deadbeef"

async def user_id(self) -> str:
async def user_id(self) -> int:
return self._user_id

async def authenticated(self) -> bool:
Expand Down

0 comments on commit e8bead4

Please sign in to comment.