ni / ni/measurement-plugin-python
Infer `enum_type` from default value
Nobody has claimed this yet.
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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