Skip to content

Commit 619febe

Browse files
committed
Update dependency frequenz-client-base to 0.8.0
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 3bc57c9 commit 619febe

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,4 @@
22

33
## Summary
44

5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
11-
## New Features
12-
13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14-
15-
## Bug Fixes
16-
17-
* The client was broken due to wrong usage of the new BaseClient API.
5+
* The base client dependency was updated to v0.8.0.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ requires-python = ">= 3.11, < 4"
3838
dependencies = [
3939
"typing-extensions >= 4.6.1, < 5",
4040
"frequenz-api-dispatch == 1.0.0-rc1",
41-
"frequenz-client-base >= 0.7.0, < 0.8.0",
41+
"frequenz-client-base >= 0.8.0, < 0.9.0",
4242
"frequenz-client-common >= 0.1.0, < 0.3.0",
4343
"grpcio >= 1.66.1, < 2",
4444
]

src/frequenz/client/dispatch/_client.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
DEFAULT_DISPATCH_PORT = 50051
5353

5454

55-
class Client(BaseApiClient):
55+
class Client(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
5656
"""Dispatch API client."""
5757

5858
streams: dict[
@@ -76,6 +76,7 @@ def __init__(
7676
"""
7777
super().__init__(
7878
server_url,
79+
dispatch_pb2_grpc.MicrogridDispatchServiceStub,
7980
connect=connect,
8081
channel_defaults=ChannelOptions(
8182
port=DEFAULT_DISPATCH_PORT,
@@ -90,21 +91,17 @@ def __init__(
9091
),
9192
)
9293
self._metadata = (("key", key),)
93-
self._setup_stub()
94-
95-
def _setup_stub(self) -> None:
96-
stub = dispatch_pb2_grpc.MicrogridDispatchServiceStub(self.channel)
97-
# We need the type: ignore here because the generated async stub only lives in
98-
# the .pyi file (the interpreter doesn't know anything about it) so we can't use
99-
# a proper `cast()`, we can only use the async stub as a type hint.
100-
self._stub: dispatch_pb2_grpc.MicrogridDispatchServiceAsyncStub = stub # type: ignore
10194

10295
@property
10396
def stub(self) -> dispatch_pb2_grpc.MicrogridDispatchServiceAsyncStub:
10497
"""The stub for the service."""
105-
if self._channel is None:
98+
if self._channel is None or self._stub is None:
10699
raise ClientNotConnected(server_url=self.server_url, operation="stub")
107-
return self._stub
100+
# This type: ignore is needed because we need to cast the sync stub to
101+
# the async stub, but we can't use cast because the async stub doesn't
102+
# actually exists to the eyes of the interpreter, it only exists for the
103+
# type-checker, so it can only be used for type hints.
104+
return self._stub # type: ignore
108105

109106
# pylint: disable=too-many-arguments, too-many-locals
110107
async def list(

src/frequenz/client/dispatch/test/client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def stub(self) -> FakeService: # type: ignore
3434
"""
3535
return self._stuba
3636

37-
def _setup_stub(self) -> None:
38-
"""Empty body because no setup needed."""
39-
4037
def dispatches(self, microgrid_id: int) -> list[Dispatch]:
4138
"""List of dispatches.
4239

0 commit comments

Comments
 (0)