pierrejeambrun commented on code in PR #44226:
URL: https://github.com/apache/airflow/pull/44226#discussion_r1851568571


##########
airflow/api_fastapi/common/db/common.py:
##########
@@ -47,40 +52,45 @@ def your_route(session: Annotated[Session, 
Depends(get_session)]):
         yield session
 
 
-def apply_filters_to_select(base_select: Select, filters: Sequence[BaseParam | 
None]) -> Select:
-    base_select = base_select
-    for filter in filters:
-        if filter is None:
+def apply_filters_to_select(
+    *, base_select: Select, filters: Sequence[BaseParam | None] | None = None
+) -> Select:
+    if filters is None:
+        return base_select
+    for f in filters:
+        if f is None:
             continue
-        base_select = filter.to_orm(base_select)
+        base_select = f.to_orm(base_select)
 
     return base_select
 
 
 @provide_session
 def paginated_select(
     base_select: Select,
-    filters: Sequence[BaseParam],
+    filters: Sequence[BaseParam] | None = None,
     order_by: BaseParam | None = None,
     offset: BaseParam | None = None,
     limit: BaseParam | None = None,
     session: Session = NEW_SESSION,
     return_total_entries: bool = True,
-) -> Select:
+) -> tuple[Select, int | None]:
     base_select = apply_filters_to_select(
-        base_select,
-        filters,
+        base_select=base_select,
+        filters=filters,
     )
 
     total_entries = None
     if return_total_entries:
         total_entries = get_query_count(base_select, session=session)
+    if TYPE_CHECKING:
+        assert isinstance(total_entries, int)

Review Comment:
   What is the purpose of these code blocks ?
   
   As I understand, at type checking time, the function `get_query_count` is 
typed to return `int`. (static tool should not have any trouble with that).
   
   At run time this is ignored anyway.
   
   I might be missing something.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to