Conversation
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.
|
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 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 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. |
|
Closing this old PR. If anybody is interesting in contributing a feature like this, we can open a new one and have a discussion. |
|
We refactored the module layout to export public types from public submodules/subpackages in: |
Create the
nidaqmx/channels.pyfile 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 theChannelclass 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
nidaqmxfor more than a year, and it has not caused any troubles.