Skip to content

Commit

Permalink
Remove restrictions from enums/defaults (#432)
Browse files Browse the repository at this point in the history
Signed-off-by: Sambhav Kothari <[email protected]>
  • Loading branch information
sambhav authored Feb 17, 2023
1 parent 1a53d3c commit e0be53f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/hera/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ def __init__(
) -> None:
if value is not MISSING and value_from is not None:
raise ValueError("Cannot specify both `value` and `value_from` when instantiating `Parameter`")
if enum and value is not MISSING and value not in enum:
raise ValueError("`value` must be in `enum`")
if enum and default is not MISSING and default not in enum:
raise ValueError("`default` must be in `enum`")
self.name = name
self.value = _serialize(value)
self.default = _serialize(default)
Expand Down
10 changes: 0 additions & 10 deletions tests/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ def test_init_raises_value_error_using_value_and_value_from(self):
Parameter("a", value_from=ValueFrom(default="42"), value="42")
assert str(e.value) == "Cannot specify both `value` and `value_from` when instantiating `Parameter`"

def test_init_raises_value_error_using_invalid_value_with_enum(self):
with pytest.raises(ValueError) as e:
Parameter("a", value="42", enum=["41"])
assert str(e.value) == "`value` must be in `enum`"

def test_init_raises_value_error_using_invalid_default_with_enum(self):
with pytest.raises(ValueError) as e:
Parameter("a", default="42", enum=["41"])
assert str(e.value) == "`default` must be in `enum`"

def test_as_name_returns_expected_parameter(self):
p = Parameter("a", value="42").as_name("b")
assert isinstance(p, Parameter)
Expand Down

0 comments on commit e0be53f

Please sign in to comment.