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

Create channels.py #458

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Create channels.py #458

wants to merge 1 commit into from

Conversation

StSav012
Copy link

Create the nidaqmx/channels.py file to import the channel types gracefully.

The file improves typing annotations. Without the file, there are warnings about accessing _task_modules, which is a private module, when getting the Channel class or its subclasses.

What does this Pull Request accomplish?

Expose channel classes from nidaqmx._task_modules.channels, primarily for typing annotations, but not limiting to it.

Why should this Pull Request be merged?

As Python has adopted optional typing annotations, various IDEs help writing code by providing the methods available for a variable. This significantly increases the speed of the code writing, without damaging the quality. Unfortunately, without the file I propose, I can't annotate, for instance, what the Task.ai_channels.add_ai_voltage_chan() function returns.

What testing has been done?

No regression testing has been done by me, for it requires a piece of hardware I'm not allowed to use for the purpose of the testing. However, I do use the code in my copy of nidaqmx for more than a year, and it has not caused any troubles.

Create the `nidaqmx/channels.py` file to import the channel types gracefully.
The file improves typing annotations. Without the file, there are warnings about accessing `_task_modules`, which is a private module, when getting the `Channel` class or its subclasses.
@bkeryan
Copy link
Collaborator

bkeryan commented Nov 20, 2023

Hi @StSav012, thank you for your contribution. Making types public to support type hints is a prerequisite for #209 and I recognize that it has value even before type hints are added for the nidaqmx module itself.

I have been using type hints for nidaqmx-python and nimi-python types in another project. Mypy treats all of the types from these packages as Any due to --ignore-missing-imports, but type hints still improve the accuracy of autocomplete in Visual Studio Code and other LSP-aware editors.

I'm currently out of office for the Thanksgiving holiday. I would like to sync up with the other nidaqmx-python code owners regarding where the other types (channel collections, timing/triggering, etc.) belong and whether we should create aliases as you have proposed or reorganize the source tree to make the internal submodules public.

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

Successfully merging this pull request may close these issues.

2 participants