From c890d5941098e19f39e1d78e40793c99f90dc654 Mon Sep 17 00:00:00 2001 From: rdimaio Date: Thu, 25 Apr 2024 16:33:17 +0200 Subject: [PATCH] Testing: Add type annotations to db/sqla/__init__; #6588 --- lib/rucio/db/sqla/__init__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rucio/db/sqla/__init__.py b/lib/rucio/db/sqla/__init__.py index 33d61fb1d9..18afa19371 100644 --- a/lib/rucio/db/sqla/__init__.py +++ b/lib/rucio/db/sqla/__init__.py @@ -12,10 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import TYPE_CHECKING, Optional, TypeVar + from sqlalchemy.sql.expression import bindparam, text +if TYPE_CHECKING: + from sqlalchemy.orm import Session + from sqlalchemy.sql.base import Executable + + Q = TypeVar('Q', Executable) + -def filter_thread_work(session, query, total_threads, thread_id, hash_variable=None): +def filter_thread_work( + session: "Session", + query: "Q", + total_threads: Optional[int], + thread_id: Optional[int], + hash_variable: Optional[str] = None +) -> "Q": """ Filters a query to partition thread workloads based on the thread id and total number of threads """ if thread_id is not None and total_threads is not None and (total_threads - 1) > 0: if session.bind.dialect.name == 'oracle':