NI-DCPower: `Measurement` named tuple does not work with type annotations
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- developer-experience
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.
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.
- Dominant language
- Python
- Stars
- 128
- Forks
- 110
- Avg merge
- 5d 14h
- Merged PRs (30d)
- 10
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.
More from ni/nimi-python
-
docs nitclk priority-low
Difficulty 1/5 Under an hour Newbie friendliness 68/100
ni/nimi-python#1993 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
ni/nimi-python#2164 · 1 comment ·
-
bug docs
Difficulty 1/5 Under an hour Newbie friendliness 48/100
ni/nimi-python#2162 ·
-
codegen enhancement
Difficulty 4/5 3-5 days Newbie friendliness 42/100
ni/nimi-python#2148 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
ni/nimi-python#2122 ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Openarea: ci bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-connect#1057 ·