Skip to content

Commit

Permalink
Revert "Also copy Literals outside of experimental feature"
Browse files Browse the repository at this point in the history
This reverts commit 3ee9ef3.

Signed-off-by: Alice Purcell <[email protected]>
  • Loading branch information
alicederyn committed Nov 5, 2024
1 parent 4be649c commit db30f6f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
7 changes: 0 additions & 7 deletions src/hera/shared/_type_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ def get_workflow_annotation(annotation: Any) -> Optional[Union[Artifact, Paramet
return metadata[0]


def add_metadata_from_type(parameter: Parameter, annotation: Any) -> None:
if not parameter.enum:
type_ = unwrap_annotation(annotation)
if get_origin(type_) is Literal:
parameter.enum = list(get_args(type_))


def construct_io_from_annotation(python_name: str, annotation: Any) -> Union[Parameter, Artifact]:
"""Constructs a Parameter or Artifact object based on annotations.
Expand Down
2 changes: 0 additions & 2 deletions src/hera/workflows/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
)
from hera.shared._pydantic import _PYDANTIC_VERSION, root_validator, validator
from hera.shared._type_util import (
add_metadata_from_type,
construct_io_from_annotation,
get_workflow_annotation,
is_subscripted,
Expand Down Expand Up @@ -380,7 +379,6 @@ def _get_parameters_from_callable(source: Callable) -> List[Parameter]:
default = MISSING

param = Parameter(name=p.name, default=default)
add_metadata_from_type(param, p.annotation)
parameters.append(param)

return parameters
Expand Down
6 changes: 2 additions & 4 deletions tests/test_script_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,10 @@ def test_script_with_param(global_config_fixture, module_name):
pytest.param("tests.script_annotations.pydantic_io_literals", "my_str", id="pydantic-io"),
],
)
@pytest.mark.parametrize("experimental_feature", ["", "script_annotations", "script_pydantic_io"])
def test_script_literals(global_config_fixture, module_name, input_name, experimental_feature):
def test_script_literals(global_config_fixture, module_name, input_name):
"""Test that Literals work correctly as direct type annotations."""
# GIVEN
if experimental_feature:
global_config_fixture.experimental_features[experimental_feature] = True
global_config_fixture.experimental_features["script_annotations"] = True

# Force a reload of the test module, as the runner performs "importlib.import_module", which
# may fetch a cached version
Expand Down

0 comments on commit db30f6f

Please sign in to comment.