Skip to content

Commit

Permalink
remove flag and make 1 default exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
drapail committed Nov 3, 2023
1 parent 2d508e6 commit 4969d31
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
7 changes: 1 addition & 6 deletions airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ def string_lower_type(val):
choices=job_states,
)

# list_import_errors
ARG_EXIT_CODE = Arg(
("--strict",), help="Return exit code '1' if there are import errors", action="store_true"
)

# next_execution
ARG_NUM_EXECUTIONS = Arg(
("-n", "--num-executions"),
Expand Down Expand Up @@ -1043,7 +1038,7 @@ class GroupCommand(NamedTuple):
name="list-import-errors",
help="List all the DAGs that have import errors",
func=lazy_load_command("airflow.cli.commands.dag_command.dag_list_import_errors"),
args=(ARG_SUBDIR, ARG_OUTPUT, ARG_VERBOSE, ARG_EXIT_CODE),
args=(ARG_SUBDIR, ARG_OUTPUT, ARG_VERBOSE),
),
ActionCommand(
name="report",
Expand Down
2 changes: 1 addition & 1 deletion airflow/cli/commands/dag_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def dag_list_import_errors(args) -> None:
data=data,
output=args.output,
)
if args.strict and data:
if data:
sys.exit(1)


Expand Down
14 changes: 0 additions & 14 deletions tests/cli/commands/test_dag_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,24 +545,10 @@ def test_cli_list_dags_prints_import_errors(self):
def test_cli_list_import_errors(self):
dag_path = os.path.join(TEST_DAGS_FOLDER, "test_invalid_cron.py")
args = self.parser.parse_args(["dags", "list", "--output", "yaml", "--subdir", dag_path])
with contextlib.redirect_stdout(StringIO()) as temp_stdout:
dag_command.dag_list_import_errors(args)
out = temp_stdout.getvalue()
assert "[0 100 * * *] is not acceptable, out of range" in out
assert dag_path in out

@conf_vars({("core", "load_examples"): "false"})
def test_cli_list_import_errors_exit_code_1(self):
dag_path = os.path.join(TEST_DAGS_FOLDER, "test_invalid_cron.py")
args = self.parser.parse_args(
["dags", "list-import-errors", "--output", "yaml", "--subdir", dag_path, "--strict"]
)
with contextlib.redirect_stdout(StringIO()) as temp_stdout:
with TestCase.assertRaises(TestCase(), SystemExit) as context:
dag_command.dag_list_import_errors(args)

out = temp_stdout.getvalue()

assert "[0 100 * * *] is not acceptable, out of range" in out
assert dag_path in out
assert context.exception.code == 1
Expand Down

0 comments on commit 4969d31

Please sign in to comment.