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


##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -102,6 +102,9 @@ def get_assets(
         limit=limit,
         session=session,
     )
+    if TYPE_CHECKING:
+        assert isinstance(total_entries, int)

Review Comment:
   Using an `@overload` on paginated_select would fix this:
   
   
   ```python
   
   
   @overload
   def paginated_select(
       base_select: Select,
       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: Literal[True] = True,
   ) -> tuple[Select, int]: ...
   
   
   @overload
   def paginated_select(
       base_select: Select,
       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: Literal[False],
   ) -> tuple[Select, None]: ...
   
   @provide_session
   def paginated_select(
       base_select: Select,
       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,
   ) -> tuple[Select, int | None]:
   ```
   
   This tells typecheckers "if you pass True for `return_total_entries` you get 
an int, else you get None.



-- 
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