NI-DCPower: `Measurement` named tuple does not work with type annotations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 128
- Forks
- 110
- Avg merge
- 5d 14h
- Merged PRs (30d)
- 10
Description
Description of issue
Some of the ni-measurementlink-service examples use type annotations like typing.List[nidcpower.Measurement], but VS Code treats the list elements as typing.Any and doesn't auto-complete field accesses. I don't think this is causing any mypy failures.
There are a couple of reasons why the Measurement named tuple doesn't work with type annotations:
Measurementis defined in the body of_SessionBase.measure_multiple, not as a module-scoped type.Measurementis defined usingnamedtupleand nottyping.NamedTuple.
System report
OS:
Name: Windows
Version: 10.0.19045
Bits: 64
Driver:
Name: NI-DCPower
Version: 22.8.0
Module:
Name: nidcpower
Version: 1.4.3
Python:
Version: 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]
Bits: 64
Is_Venv: True
Installed Packages:
pywin32==303
setuptools==65.3.0
pip==22.2.2
click==8.1.3
protobuf==4.21.12
grpcio==1.51.1
nidcpower==1.4.3
wheel==0.37.1
ni-measurementlink-service==0.12.0
colorama==0.4.6
hightime==0.2.1
Steps to reproduce issue
- Open a typing-aware editor such as VS Code and set its interpreter to a venv that has
nidcpowerinstalled. - Create or edit a .py file with
import nidcpowerat the top. - Add
measured_values: List[nidcpower.Measurement] = []. - Hover over
measured_values. The tooltip should say something like(variable) measured_values: list[nidcpower.Measurement], but it says(variable) measured_values: list. - Add
measured_values[0].channelon a separate line. - However over
channel. The tooltip should saychannel: strbut it sayschannel: Any.
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
Start by locating _SessionBase.measure_multiple and its locally defined Measurement named tuple. Review how nidcpower exposes that type and reproduce the VS Code annotation behavior described in the issue. Done means List[nidcpower.Measurement] is recognized with typed elements and field access such as channel is no longer Any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100