ashb commented on a change in pull request #13929:
URL: https://github.com/apache/airflow/pull/13929#discussion_r570901200
##########
File path: airflow/utils/session.py
##########
@@ -40,21 +40,26 @@ def create_session():
RT = TypeVar("RT") # pylint: disable=invalid-name
+def find_session_idx(func: Callable[..., RT]) -> int:
+ """Find session index in function call parameter."""
+ func_params = signature(func).parameters
+ try:
+ # func_params is an ordered dict -- this is the "recommended" way of
getting the position
+ session_args_idx = tuple(func_params).index("session")
+ except ValueError:
+ raise ValueError(f"Function {func.__qualname__} has no `session`
argument") from None
Review comment:
Nice!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]