Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer enum_type from default value #364

Open
bkeryan opened this issue Sep 1, 2023 · 0 comments
Open

Infer enum_type from default value #364

bkeryan opened this issue Sep 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@bkeryan
Copy link
Collaborator

bkeryan commented Sep 1, 2023

Problem to Solve

When specifying enum configurations, users have to specify the enum type twice: in both the default_value and enum_type parameters.

As explained in #283 (comment) , enum support uses enum_type for the annotations dictionary and uses type(parameter_metadata.default_value) when constructing enum values. This suggests that enum_type is superfluous when using the enum module (not protobuf enums).

Proposed Solution

if enum_type is None and isinstance(type(default_value), EnumMeta):
    enum_type = type(default_value)

Cc: @WesleyTangNationalInstruments

AB#2509907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant