1- from collections .abc import Generator
21import json
32from http import HTTPStatus
4- from typing import AsyncGenerator
3+ from collections . abc import AsyncGenerator
54
65from ...abstract_base_client import AbstractBaseClient
76from ...errors .custom_error import CustomError
87from ...errors .internal_error import InternalError
9- from ...errors .invalid_parameter_error import InvalidParameterError
108from ...errors .server_error import ServerError
11- from ...errors .validation_error import ValidationError
129from ...event .event import Event
13- from ...event .validate_subject import validate_subject
1410from ...http_client .response import Response
1511from ..is_event import is_event
1612from ..is_stream_error import is_stream_error
@@ -22,15 +18,7 @@ async def read_events(
2218 client : AbstractBaseClient ,
2319 subject : str ,
2420 options : ReadEventsOptions
25- ) -> AsyncGenerator [Event , None ]:
26- """try:
27- validate_subject(subject)
28- except ValidationError as validation_error:
29- raise InvalidParameterError('subject', str(validation_error)) from validation_error
30- except Exception as other_error:
31- raise InternalError(str(other_error)) from other_error
32- """
33-
21+ ) -> AsyncGenerator [Event ]:
3422 request_body = json .dumps ({
3523 'subject' : subject ,
3624 'options' : options .to_json ()
@@ -61,31 +49,26 @@ async def read_events(
6149
6250 if is_event (message ):
6351 event = Event .parse (message ['payload' ])
64-
65- event_id = int (message ['payload' ]['id' ]) # Access ID from raw payload
52+ event_id = int (message ['payload' ]['id' ])
6653
6754 if options .lower_bound is not None :
68- # For inclusive, include events with ID >= lower bound
6955 if (
7056 options .lower_bound .type == 'inclusive' and # pylint: disable=R2004
7157 int (event_id ) < int (options .lower_bound .id )
7258 ):
7359 continue
74- # For exclusive, include events with ID > lower bound
7560 if (
7661 options .lower_bound .type == 'exclusive' and # pylint: disable=R2004
7762 int (event_id ) <= int (options .lower_bound .id )
7863 ):
7964 continue
8065
8166 if options .upper_bound is not None :
82- # For inclusive, include events with ID <= upper bound
8367 if (
8468 options .upper_bound .type == 'inclusive' and # pylint: disable=R2004
8569 int (event_id ) > int (options .upper_bound .id )
8670 ):
8771 continue
88- # For exclusive, include events with ID < upper bound
8972 if (
9073 options .upper_bound .type == 'exclusive' and # pylint: disable=R2004
9174 int (event_id ) >= int (options .upper_bound .id )
0 commit comments