Skip to content

Commit e93b0b0

Browse files
authored
use MISSING vs None in parameter inference (#499)
Signed-off-by: Flaviu Vadan <[email protected]>
1 parent 924aa04 commit e93b0b0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.github/workflows/cicd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ on:
55
branches:
66
- main
77
- hera/v5
8+
- hera/v4-n-n
89
paths:
910
- "src/**"
1011
pull_request:
1112
branches:
1213
- main
1314
- hera/v5
15+
- hera/v4-n-n
1416
paths:
1517
- "src/**"
1618

src/hera/task.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from hera.memoize import Memoize
3535
from hera.metric import Metric, Metrics
3636
from hera.operator import Operator
37-
from hera.parameter import Parameter
37+
from hera.parameter import Parameter, MISSING
3838
from hera.port import ContainerPort
3939
from hera.resource_template import ResourceTemplate
4040
from hera.resources import Resources
@@ -696,12 +696,12 @@ def _deduce_input_params_from_source(self) -> List[Parameter]:
696696

697697
# If there are any kwargs arguments associated with the function signature,
698698
# we store these as we can set them as default values for argo arguments
699-
source_signature: Dict[str, Optional[str]] = {}
699+
source_signature: Dict[str, Optional[Any]] = {}
700700
for p in inspect.signature(self.source).parameters.values():
701701
if p.default != inspect.Parameter.empty and p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:
702702
source_signature[p.name] = p.default
703703
else:
704-
source_signature[p.name] = None
704+
source_signature[p.name] = MISSING
705705

706706
# Deduce input parameters from function source. Only add those which haven't been explicitly set in inputs
707707
input_params_names = [p.name for p in self.inputs if isinstance(p, Parameter)]
@@ -772,7 +772,7 @@ def _deduce_input_params_from_source(self) -> List[Parameter]:
772772
# Verify that we're utilizing 'item'
773773
if not any([p.contains_item for p in self.inputs + deduced_params]): # type: ignore
774774
raise ValueError(
775-
"`with_param` or `with_sequence` items are utilized in inputs, nor could they be deduced"
775+
"`with_param` or `with_sequence` items are not utilized in inputs, nor could they be deduced"
776776
)
777777

778778
return deduced_params

tests/test_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ def test_task_uses_sequences(self):
832832
assert t.with_sequence.format == "abc"
833833

834834
def test_task_utilize_items(self, no_op):
835-
error_string = "`with_param` or `with_sequence` items are utilized in inputs, nor could they be deduced"
835+
error_string = "`with_param` or `with_sequence` items are not utilized in inputs, nor could they be deduced"
836836
with pytest.raises(ValueError) as e:
837837
Task("t", no_op, with_sequence=Sequence("abc", start=1, end=42))
838838
assert str(e.value) == error_string

0 commit comments

Comments
 (0)