Skip to content

Support complex enum variants #119

Closed
Closed

Description

@kstreee-furiosa

Hi all, I wonder that is there any plans to support complex enum variants.

e.g., if I add variants to enum but sub-gen doesn't catch the variants for now.

#[gen_stub_pyclass_enum]
#[pyclass(eq, eq_int)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Number {
    #[pyo3(name = "FLOAT")]
    Float(f32),
    #[pyo3(name = "INTEGER")]
    Integer(usize),
    Test { a: usize, b: usize },
}

generates

class Number(Enum):
    FLOAT = auto()
    INTEGER = auto()
    Test = auto()

but wants, not sure though, pyo3 may generates additional 'class' for complex enum variants, it probably looks like following..?

class Number(Enum):
    FLOAT = auto()
    INTEGER = "INTEGER"
    Test = "Test"

class INTEGER:
    _0: int

class Test:
    a: int
    b: int

Any plans to support this feature?

Activity

  1. flying-sheep commented on Dec 12, 2024

    @flying-sheep
    Contributor

    No, it looks something like the following:

    class Number:
        class FLOAT(Number, tuple[float]): pass
        class INTEGER(Number, tuple[int]): pass
        class Test(Number):
            a: int
            b: int
  2. evonreis commented on May 29, 2025

    @evonreis
    Contributor

    New macro for enum args proposed in #208

  3. kstreee-furiosa commented on May 30, 2025

    @kstreee-furiosa
    Author

    Amazing!! I'll try the new macro when it has been merged..!

  4. termoshtt commented on Jul 19, 2025

    @termoshtt
    Member

    Resolved in #208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions