|
13 | 13 | # See the License for the specific language governing permissions and
|
14 | 14 | # limitations under the License.
|
15 | 15 | import logging
|
16 |
| -from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union |
| 16 | +from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union, cast |
17 | 17 |
|
18 | 18 | import attr
|
19 | 19 |
|
@@ -326,7 +326,7 @@ def get_after_receipt(
|
326 | 326 | )
|
327 | 327 | args = [user_id, user_id, min_stream_ordering, max_stream_ordering, limit]
|
328 | 328 | txn.execute(sql, args)
|
329 |
| - return txn.fetchall() # type: ignore[return-value] |
| 329 | + return cast(List[Tuple[str, str, int, str, bool]], txn.fetchall()) |
330 | 330 |
|
331 | 331 | after_read_receipt = await self.db_pool.runInteraction(
|
332 | 332 | "get_unread_push_actions_for_user_in_range_http_arr", get_after_receipt
|
@@ -357,7 +357,7 @@ def get_no_receipt(
|
357 | 357 | )
|
358 | 358 | args = [user_id, user_id, min_stream_ordering, max_stream_ordering, limit]
|
359 | 359 | txn.execute(sql, args)
|
360 |
| - return txn.fetchall() # type: ignore[return-value] |
| 360 | + return cast(List[Tuple[str, str, int, str, bool]], txn.fetchall()) |
361 | 361 |
|
362 | 362 | no_read_receipt = await self.db_pool.runInteraction(
|
363 | 363 | "get_unread_push_actions_for_user_in_range_http_nrr", get_no_receipt
|
@@ -434,7 +434,7 @@ def get_after_receipt(
|
434 | 434 | )
|
435 | 435 | args = [user_id, user_id, min_stream_ordering, max_stream_ordering, limit]
|
436 | 436 | txn.execute(sql, args)
|
437 |
| - return txn.fetchall() # type: ignore[return-value] |
| 437 | + return cast(List[Tuple[str, str, int, str, bool, int]], txn.fetchall()) |
438 | 438 |
|
439 | 439 | after_read_receipt = await self.db_pool.runInteraction(
|
440 | 440 | "get_unread_push_actions_for_user_in_range_email_arr", get_after_receipt
|
@@ -465,7 +465,7 @@ def get_no_receipt(
|
465 | 465 | )
|
466 | 466 | args = [user_id, user_id, min_stream_ordering, max_stream_ordering, limit]
|
467 | 467 | txn.execute(sql, args)
|
468 |
| - return txn.fetchall() # type: ignore[return-value] |
| 468 | + return cast(List[Tuple[str, str, int, str, bool, int]], txn.fetchall()) |
469 | 469 |
|
470 | 470 | no_read_receipt = await self.db_pool.runInteraction(
|
471 | 471 | "get_unread_push_actions_for_user_in_range_email_nrr", get_no_receipt
|
@@ -662,7 +662,7 @@ def _find_first_stream_ordering_after_ts_txn(
|
662 | 662 | The stream ordering
|
663 | 663 | """
|
664 | 664 | txn.execute("SELECT MAX(stream_ordering) FROM events")
|
665 |
| - max_stream_ordering = txn.fetchone()[0] # type: ignore[index] |
| 665 | + max_stream_ordering = cast(Tuple[Optional[int]], txn.fetchone())[0] |
666 | 666 |
|
667 | 667 | if max_stream_ordering is None:
|
668 | 668 | return 0
|
@@ -731,7 +731,7 @@ def f(txn: LoggingTransaction) -> Optional[Tuple[int]]:
|
731 | 731 | " LIMIT 1"
|
732 | 732 | )
|
733 | 733 | txn.execute(sql, (stream_ordering,))
|
734 |
| - return txn.fetchone() # type: ignore[return-value] |
| 734 | + return cast(Optional[Tuple[int]], txn.fetchone()) |
735 | 735 |
|
736 | 736 | result = await self.db_pool.runInteraction(
|
737 | 737 | "get_time_of_last_push_action_before", f
|
@@ -1029,7 +1029,9 @@ def f(
|
1029 | 1029 | " LIMIT ?" % (before_clause,)
|
1030 | 1030 | )
|
1031 | 1031 | txn.execute(sql, args)
|
1032 |
| - return txn.fetchall() # type: ignore[return-value] |
| 1032 | + return cast( |
| 1033 | + List[Tuple[str, str, int, int, str, bool, str, int]], txn.fetchall() |
| 1034 | + ) |
1033 | 1035 |
|
1034 | 1036 | push_actions = await self.db_pool.runInteraction("get_push_actions_for_user", f)
|
1035 | 1037 | return [
|
|
0 commit comments