Skip to content

Commit

Permalink
Fix static check failures in PR #218 (#251)
Browse files Browse the repository at this point in the history
Fix the failed Static Check job here that were observed in #218.
Since the PR was created from a fork, I could not push changes to it
before merging.

related: #206
  • Loading branch information
pankajkoti authored Oct 16, 2024
1 parent 93e32e6 commit 6f31846
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
24 changes: 8 additions & 16 deletions dagfactory/dagbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,22 @@ def get_dag_params(self) -> Dict[str, Any]:
dag_params["on_failure_callback_file"],
)

if utils.check_dict_key(
dag_params["default_args"], "on_success_callback_name"
) and utils.check_dict_key(
if utils.check_dict_key(dag_params["default_args"], "on_success_callback_name") and utils.check_dict_key(
dag_params["default_args"], "on_success_callback_file"
):

dag_params["default_args"]["on_success_callback"]: Callable = (
utils.get_python_callable(
dag_params["default_args"]["on_success_callback_name"],
dag_params["default_args"]["on_success_callback_file"],
)
dag_params["default_args"]["on_success_callback"]: Callable = utils.get_python_callable(
dag_params["default_args"]["on_success_callback_name"],
dag_params["default_args"]["on_success_callback_file"],
)

if utils.check_dict_key(
dag_params["default_args"], "on_failure_callback_name"
) and utils.check_dict_key(
if utils.check_dict_key(dag_params["default_args"], "on_failure_callback_name") and utils.check_dict_key(
dag_params["default_args"], "on_failure_callback_file"
):

dag_params["default_args"]["on_failure_callback"]: Callable = (
utils.get_python_callable(
dag_params["default_args"]["on_failure_callback_name"],
dag_params["default_args"]["on_failure_callback_file"],
)
dag_params["default_args"]["on_failure_callback"]: Callable = utils.get_python_callable(
dag_params["default_args"]["on_failure_callback_name"],
dag_params["default_args"]["on_failure_callback_file"],
)

if utils.check_dict_key(dag_params, "template_searchpath"):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_dagbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ def test_make_python_operator():
assert callable(actual.python_callable)
assert isinstance(actual, PythonOperator)


def test_make_python_operator_with_callable_str():
td = dagbuilder.DagBuilder("test_dag", DAG_CONFIG, DEFAULT_CONFIG)
operator = "airflow.operators.python_operator.PythonOperator"
Expand All @@ -428,7 +429,8 @@ def test_make_python_operator_with_callable_str():
assert actual.task_id == "test_task"
assert callable(actual.python_callable)
assert isinstance(actual, PythonOperator)



def test_make_python_operator_missing_param():
td = dagbuilder.DagBuilder("test_dag", DAG_CONFIG, DEFAULT_CONFIG)
operator = "airflow.operators.python_operator.PythonOperator"
Expand Down

0 comments on commit 6f31846

Please sign in to comment.