Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static check failures in PR #218 #251

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading