ni / ni/measurement-plugin-python

Infer `enum_type` from default value

Open
#364 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
21
Forks
20
Avg merge
1d 16h
Merged PRs (30d)
3

Description

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 https://github.com/ni/measurementlink-python/issues/283#issuecomment-1703282982 , 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the Python implementation for handling enum_type, default_value, and enum configurations, then inspect any related tests. Confirm that a standard-library enum default can supply enum_type when it is omitted, while protobuf enum behavior remains unchanged; add or update coverage for the inferred and explicitly supplied cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.