Skip to content

Commit

Permalink
Remove short option for description argument and update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenye-Na committed Oct 15, 2023
1 parent 8c5c6df commit 15f764c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,7 @@ def string_lower_type(val):
("-d", "--default"), metavar="VAL", default=None, help="Default value returned if variable does not exist"
)
ARG_VAR_DESCRIPTION = Arg(
(
"-desc",
"--description",
),
("--description",),
default=None,
required=False,
help="Variable description, optional when setting a variable",
Expand Down
2 changes: 1 addition & 1 deletion airflow/cli/commands/variable_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def variables_get(args):
@providers_configuration_loaded
def variables_set(args):
"""Create new variable with a given name, value and description."""
Variable.set(args.key, args.value, args.description or None, serialize_json=args.json)
Variable.set(args.key, args.value, args.description, serialize_json=args.json)
print(f"Variable {args.key} created")


Expand Down
8 changes: 1 addition & 7 deletions tests/cli/commands/test_variable_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ def test_variables_set(self):
def test_variables_set_with_description(self):
"""Test variable_set command with optional description argument"""
variable_command.variables_set(
self.parser.parse_args(["variables", "set", "foo", "bar", "--desc", "foo_bar_description"])
self.parser.parse_args(["variables", "set", "foo", "bar", "--description", "foo_bar_description"])
)
assert Variable.get("foo") is not None

variable_command.variables_set(
self.parser.parse_args(["variables", "set", "bar", "foo", "--description", "bar_foo_description"])
)
assert Variable.get("bar") is not None

with pytest.raises(KeyError):
Variable.get("foo1")

Expand Down

0 comments on commit 15f764c

Please sign in to comment.