-
Notifications
You must be signed in to change notification settings - Fork 190
Fix several API typos and document the process in CONTRIBUTING.md #943
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,15 @@ All notable changes to this project will be documented in this file. | |||||
|
|
||||||
| * ### Major Changes | ||||||
| * [cspell](https://cspell.org/) is now used for spell checking. | ||||||
| * The following `DAQmxErrors` enum members were renamed to fix typos inherited from the C API: | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "inherited from the C API" makes it sound like this is not under our control, which is not the case.
Suggested change
|
||||||
| * `FILTER_DELAY_REMOVAL_NOT_POSSSIBLE_WITH_ANALOG_TRIGGER` → `FILTER_DELAY_REMOVAL_NOT_POSSIBLE_WITH_ANALOG_TRIGGER` | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re: the arrows: fine, I guess? |
||||||
| * `INVALID_ATTENTUATION_BASED_ON_MIN_MAX` → `INVALID_ATTENUATION_BASED_ON_MIN_MAX` | ||||||
| * `INVALIDC_DAQ_SYNC_PORT_CONNECTION_FORMAT` → `INVALID_CDAQ_SYNC_PORT_CONNECTION_FORMAT` | ||||||
| * `MAX_SOUND_PRESSURE_MIC_SENSITIVIT_RELATED_AI_PROPERTIES_NOT_SUPPORTED_BY_DEV` → `MAX_SOUND_PRESSURE_MIC_SENSITIVITY_RELATED_AI_PROPERTIES_NOT_SUPPORTED_BY_DEV` | ||||||
| * `MULTIPLE_SUBSYTEM_CALIBRATION` → `MULTIPLE_SUBSYSTEM_CALIBRATION` | ||||||
| * `ONLY_PEM_OR_DER_CERTITICATES_ACCEPTED` → `ONLY_PEM_OR_DER_CERTIFICATES_ACCEPTED` | ||||||
|
|
||||||
| The old names are preserved as aliases for backward compatibility. | ||||||
|
|
||||||
| * ### Known Issues | ||||||
| * ... | ||||||
|
|
||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't document how to fix specific types of typos. They should be rare and documenting this makes the document harder to read and maintain. I think it's ok to include some basic guidelines:
|
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will have to be updated if/when the misspellings are fixed in the internal DAQmx metadata. The substitutions will need to be reversed, so that it adds the misspellings instead of fixing them. Here's another way to fix the misspellings that wouldn't have this problem:
This way, the compatibility items will still exist if/when the misspellings are fixed upstream. |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are not fixing the misspellings in the metadata at this time, please file a bug to the Platform Drivers Venus team about the misspellings in the C and .NET APIs. Thankfully, https://github.com/ni/grpc-device/blob/main/generated/nidaqmx/nidaqmx.proto is not affected because it doesn't include error code constants. |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In nidaqmx-python, we generally name component/unit tests after the module that we are testing. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """Tests for error code renames that fixed typos inherited from the C API.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from nidaqmx.error_codes import DAQmxErrors | ||
|
|
||
| # Each tuple is (old_typo_name, new_correct_name). | ||
| _RENAMED_ERROR_CODES = [ | ||
| ( | ||
| "FILTER_DELAY_REMOVAL_NOT_POSSSIBLE_WITH_ANALOG_TRIGGER", | ||
| "FILTER_DELAY_REMOVAL_NOT_POSSIBLE_WITH_ANALOG_TRIGGER", | ||
| ), | ||
| ( | ||
| "INVALID_ATTENTUATION_BASED_ON_MIN_MAX", | ||
| "INVALID_ATTENUATION_BASED_ON_MIN_MAX", | ||
| ), | ||
| ( | ||
| "INVALIDC_DAQ_SYNC_PORT_CONNECTION_FORMAT", | ||
| "INVALID_CDAQ_SYNC_PORT_CONNECTION_FORMAT", | ||
| ), | ||
| ( | ||
| "MAX_SOUND_PRESSURE_MIC_SENSITIVIT_RELATED_AI_PROPERTIES_NOT_SUPPORTED_BY_DEV", | ||
| "MAX_SOUND_PRESSURE_MIC_SENSITIVITY_RELATED_AI_PROPERTIES_NOT_SUPPORTED_BY_DEV", | ||
| ), | ||
| ( | ||
| "MULTIPLE_SUBSYTEM_CALIBRATION", | ||
| "MULTIPLE_SUBSYSTEM_CALIBRATION", | ||
| ), | ||
| ( | ||
| "ONLY_PEM_OR_DER_CERTITICATES_ACCEPTED", | ||
| "ONLY_PEM_OR_DER_CERTIFICATES_ACCEPTED", | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("old_name,new_name", _RENAMED_ERROR_CODES) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this instance, I do not think that parametrization has any advantage over the simple approach: |
||
| def test___renamed_error_code___old_and_new_names___refer_to_same_member( | ||
| old_name: str, new_name: str | ||
| ) -> None: | ||
| old_member = DAQmxErrors[old_name] | ||
| new_member = DAQmxErrors[new_name] | ||
| assert old_member is new_member | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including misspelled words like "attentuation" in the dictionary allows us to use the same misspelling elsewhere.
I think it would be better to put the misspelled constant in the dictionary (e.g. "INVALID_ATTENTUATION_BASED_ON_MIN_MAX") so that we catch other instances of the misspelled word.