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

⬆️ Update dependency ruff to v0.1.15 #575

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ yarl = ">=1.6.0"
Changelog = "https://github.com/klaasnicolaas/python-gridnet/releases"

[tool.poetry.group.dev.dependencies]
ruff = "0.1.14"
ruff = "0.1.15"
aresponses = "3.0.0"
blacken-docs = "1.16.0"
codespell = "2.2.6"
Expand Down
13 changes: 7 additions & 6 deletions src/gridnet/gridnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def _request(
------
GridNetConnectionError: An error occurred while
communicating with the device.

"""
version = metadata.version(__package__)
url = URL.build(scheme="http", host=self.host, path="/").join(URL(uri))
Expand All @@ -74,17 +75,13 @@ async def _request(
response.raise_for_status()
except asyncio.TimeoutError as exception:
msg = f"Timeout occurred while connecting to {self.host}"
raise GridNetConnectionError(
msg,
) from exception
raise GridNetConnectionError(msg) from exception
except (
ClientError,
socket.gaierror,
) as exception:
msg = f"Error occurred while communicating with {self.host}"
raise GridNetConnectionError(
msg,
) from exception
raise GridNetConnectionError(msg) from exception

return cast(dict[str, Any], json.loads(await response.text()))

Expand All @@ -94,6 +91,7 @@ async def device(self) -> Device:
Returns
-------
A Device data object from the API.

"""
data = await self._request("info")
return Device.from_dict(data)
Expand All @@ -104,6 +102,7 @@ async def smartbridge(self) -> SmartBridge:
Returns
-------
A SmartBridge data object from the API.

"""
data = await self._request("meter/now")
return SmartBridge.from_dict(data)
Expand All @@ -119,6 +118,7 @@ async def __aenter__(self) -> Self:
Returns
-------
The GridNet object.

"""
return self

Expand All @@ -128,5 +128,6 @@ async def __aexit__(self, *_exc_info: object) -> None:
Args:
----
_exc_info: Exec type.

"""
await self.close()
3 changes: 3 additions & 0 deletions src/gridnet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def from_dict(data: dict[str, Any]) -> SmartBridge:
Returns:
-------
A SmartBridge object.

"""
data = data["elec"]

Expand All @@ -37,6 +38,7 @@ def convert(value: float) -> float:
Returns:
-------
Value in kWh rounded with 1 decimal.

"""
value = value / 1000
return float(round(value, 1))
Expand Down Expand Up @@ -70,6 +72,7 @@ def from_dict(data: dict[str, Any]) -> Device:
Returns:
-------
A Device object.

"""
return Device(
n2g_id=data["id"],
Expand Down