ni / ni/nimi-python

Repeated capability accessors return internal `_SessionBase` type

Open
#2,019 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
128
Forks
110
Avg merge
5d 14h
Merged PRs (30d)
10

Description

Description of issue

Repeated capability accessors like Session.channels and Session.instruments return a _SessionBase object. Clients that pass channel objects around may need to refer to this type in PEP 484 type hints.

Example: https://github.com/ni/measurementlink-python/blob/9bffe48c1c2da4777eeca0ca159b74bde724ead6/examples/output_voltage_measurement/measurement.py#L177

def _wait_for_source_complete_event(
    measurement_service: nims.MeasurementService,
    channels: nidcpower._SessionBase,
    cancellation_event: threading.Event,
) -> None: ...

The convention recommended in PEP8 and used by most Python code is that names with a single leading underscore are for internal use.

In general, public APIs ought to use public types.

System report

Not applicable.

Steps to reproduce issue
  1. Write a function that accepts a channel object (such as the linked example).
  2. Write PEP 484 type hints for this function.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementations and type annotations for repeated capability accessors such as Session.channels and Session.instruments, then compare them with the usage in examples/output_voltage_measurement/measurement.py around line 177. Done means clients can use a public type for channel objects in PEP 484 annotations instead of referring to the internal _SessionBase type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.