|
22 | 22 | # for better readability. Even though it is not necessary, |
23 | 23 | # it makes the return type clear without needing to read any |
24 | 24 | # documentation or code. |
| 25 | + |
| 26 | + |
25 | 27 | async def read_events( |
26 | 28 | client: AbstractBaseClient, |
27 | 29 | subject: str, |
@@ -71,28 +73,40 @@ async def read_events( |
71 | 73 |
|
72 | 74 | if is_event(message): |
73 | 75 | event = Event.parse(message['payload']) |
74 | | - |
| 76 | + |
75 | 77 | event_id = int(message['payload']['id']) # Access ID from raw payload |
76 | 78 |
|
77 | 79 | if options.lower_bound is not None: |
78 | 80 | # For inclusive, include events with ID >= lower bound |
79 | | - if options.lower_bound.type == 'inclusive' and event_id < options.lower_bound.id: |
| 81 | + if ( |
| 82 | + options.lower_bound.type == 'inclusive' and # pylint: disable=R2004 |
| 83 | + int(event_id) < int(options.lower_bound.id) |
| 84 | + ): |
80 | 85 | continue |
81 | 86 | # For exclusive, include events with ID > lower bound |
82 | | - if options.lower_bound.type == 'exclusive' and event_id <= options.lower_bound.id: |
| 87 | + if ( |
| 88 | + options.lower_bound.type == 'exclusive' and # pylint: disable=R2004 |
| 89 | + int(event_id) <= int(options.lower_bound.id) |
| 90 | + ): |
83 | 91 | continue |
84 | | - |
| 92 | + |
85 | 93 | if options.upper_bound is not None: |
86 | 94 | # For inclusive, include events with ID <= upper bound |
87 | | - if options.upper_bound.type == 'inclusive' and event_id > options.upper_bound.id: |
| 95 | + if ( |
| 96 | + options.upper_bound.type == 'inclusive' and # pylint: disable=R2004 |
| 97 | + int(event_id) > int(options.upper_bound.id) |
| 98 | + ): |
88 | 99 | continue |
89 | 100 | # For exclusive, include events with ID < upper bound |
90 | | - if options.upper_bound.type == 'exclusive' and event_id >= options.upper_bound.id: |
| 101 | + if ( |
| 102 | + options.upper_bound.type == 'exclusive' and # pylint: disable=R2004 |
| 103 | + int(event_id) >= int(options.upper_bound.id) |
| 104 | + ): |
91 | 105 | continue |
92 | 106 |
|
93 | 107 | yield StoreItem(event, message['payload']['hash']) |
94 | 108 | continue |
95 | | - |
| 109 | + |
96 | 110 | raise ServerError( |
97 | 111 | f'Failed to read events, an unexpected stream item was received: ' |
98 | 112 | f'{message}.' |
|
0 commit comments