2929 MarketLocationsFilter ,
3030 MarketLocationUpdate ,
3131 MetricType ,
32- MetricUnit ,
3332 PaginationParams ,
3433 ResamplingOptions ,
3534 RevisionSelection ,
3635 UpsertResult ,
37- MarketLocationSample ,
3836)
3937
4038DEFAULT_PORT = 443
@@ -159,16 +157,12 @@ def stream_timeout(self) -> timedelta:
159157 @property
160158 def stub (self ) -> marketmetering_pb2_grpc .MarketMeteringServiceStub :
161159 """The stub for the service."""
162- # If we have an injected mock stub (for testing), return it directly
163- if self ._stub is not None :
164- return self ._stub # type: ignore
165-
166- if self ._channel is None :
160+ if self ._channel is None or self ._stub is None :
167161 raise ClientNotConnected (server_url = self .server_url , operation = "stub" )
168162 # This type: ignore is needed because we need to cast the sync stub to
169163 # the async stub, but we can't use cast because the async stub doesn't
170164 # actually exist to the eyes of the interpreter.
171- return self ._stub # type: ignore
165+ return self ._stub # type: ignore[return-value]
172166
173167 async def create_market_location (
174168 self ,
@@ -186,7 +180,7 @@ async def create_market_location(
186180 market_location_ref = market_location_ref .to_protobuf (),
187181 market_location = market_location .to_protobuf (),
188182 )
189- await self .stub .CreateMarketLocation (
183+ await self .stub .CreateMarketLocation ( # type: ignore[misc]
190184 request ,
191185 timeout = self ._call_timeout_seconds ,
192186 )
@@ -209,7 +203,7 @@ async def update_market_location(
209203 update_fields = update_pb ,
210204 update_mask = update_mask_pb ,
211205 )
212- await self .stub .UpdateMarketLocation (
206+ await self .stub .UpdateMarketLocation ( # type: ignore[misc]
213207 request ,
214208 timeout = self ._call_timeout_seconds ,
215209 )
@@ -227,7 +221,7 @@ async def activate_market_location(
227221 request = pb .ActivateMarketLocationRequest (
228222 market_location_refs = [market_location_ref .to_protobuf ()],
229223 )
230- await self .stub .ActivateMarketLocation (
224+ await self .stub .ActivateMarketLocation ( # type: ignore[misc]
231225 request ,
232226 timeout = self ._call_timeout_seconds ,
233227 )
@@ -245,7 +239,7 @@ async def deactivate_market_location(
245239 request = pb .DeactivateMarketLocationRequest (
246240 market_location_refs = [market_location_ref .to_protobuf ()],
247241 )
248- await self .stub .DeactivateMarketLocation (
242+ await self .stub .DeactivateMarketLocation ( # type: ignore[misc]
249243 request ,
250244 timeout = self ._call_timeout_seconds ,
251245 )
@@ -280,7 +274,7 @@ async def list_market_locations(
280274 pagination_params .to_protobuf () if pagination_params else None
281275 ),
282276 )
283- response = await self .stub .ListMarketLocations (
277+ response = await self .stub .ListMarketLocations ( # type: ignore[misc]
284278 request ,
285279 timeout = self ._call_timeout_seconds ,
286280 )
@@ -311,9 +305,9 @@ async def upsert_samples(
311305 UpsertResult objects indicating success or failure for each sample.
312306 """
313307
314- async def request_generator () -> AsyncIterator [
315- pb .UpsertMarketLocationSamplesStreamRequest
316- ] :
308+ async def request_generator () -> (
309+ AsyncIterator [ pb .UpsertMarketLocationSamplesStreamRequest ]
310+ ) :
317311 async for ml_ref , series in samples_stream :
318312 for sample in series .samples :
319313 yield pb .UpsertMarketLocationSamplesStreamRequest (
@@ -326,7 +320,7 @@ async def request_generator() -> AsyncIterator[
326320
327321 response_stream = cast (
328322 AsyncIterator [pb .UpsertMarketLocationSamplesStreamResponse ],
329- self .stub .UpsertMarketLocationSamplesStream (
323+ self .stub .UpsertMarketLocationSamplesStream ( # type: ignore[arg-type]
330324 request_generator (),
331325 timeout = self ._stream_timeout_seconds ,
332326 ),
0 commit comments