#The CLI is not respecting the default enum value argument with the python SDK?

1 messages · Page 1 of 1 (latest)

slate egret
#

I have the following code

from typing import Annotated
import dagger
from enum import Enum

@dagger.enum_type
class TestEnum(str, Enum):
    A = "a"
    B = "b"

TestArrayType = Annotated[list[TestEnum], dagger.Doc("Test array.")]
TestType = Annotated[TestEnum, dagger.Doc("Test.")]

@dagger.object_type
class Test:
    """Test class."""

    @dagger.function
    def test_array(self, t: TestArrayType = [TestEnum.A]) -> str:
        return str(t)

    @dagger.function
    def test(self, t: TestType = TestEnum.A) -> str:
        return str(t)

Running help is returning:

$ dagger call test-array --help
USAGE
  dagger call test-array [arguments]

ARGUMENTS
      --t []A,B   Test array. (default [])

and:

$ dagger call test --help
USAGE
  dagger call test [arguments]

ARGUMENTS
      --t A,B   Test.

I would expect the default value appearing in the help description.
How should I set the default value to appear it in cli help?

floral tangle
#

Hi 👋 this could be specific to enums, I can dig deeper, but could it be because class Test is declared twice? once as @dagger.object_type and once as @dagger.enum_type?

slate egret
#

Hi Kyle,
The code snippet I sent was a bit oversimplified to isolate the issue. I noticed the mistake—it should be TestEnum instead of Test, and I'll get that fixed. However, the behavior is still exactly as I described.

floral tangle