diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89325dd44..493973236 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,11 +25,11 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: .venv - key: nidaqmx-all-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} + key: nidaqmx-all-extras-and-examples-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - name: Install dependencies run: | python -m pip install --upgrade pip - poetry install --all-extras + poetry install --all-extras --with examples - name: Run linters run: poetry run ni-python-styleguide lint - name: Run mypy (Linux) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90e4d58b4..fa0ede477 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ To contribute to this project, it is recommended that you follow these steps: 1. Ensure you have [poetry](https://python-poetry.org/) [installed](https://python-poetry.org/docs/#installation) 2. Clone the repository using `git clone https://github.com/ni/nidaqmx-python.git` 3. Get the submodules using `git submodule update --init --recursive` -3. Install **nidaqmx** dependencies using `poetry install --all-extras` +3. Install **nidaqmx** dependencies using `poetry install --all-extras --with examples` 4. Run the regression tests on your system (see Testing section). At this point, if any tests fail, do not begin development. Try to investigate these failures. If you're unable to do so, report an issue through our [GitHub issues page](http://github.com/ni/nidaqmx-python/issues). diff --git a/examples/digital_out/gen_dig_line_int_clk.py b/examples/digital_out/gen_dig_line_int_clk.py index 260bfd48c..8808863bf 100644 --- a/examples/digital_out/gen_dig_line_int_clk.py +++ b/examples/digital_out/gen_dig_line_int_clk.py @@ -8,7 +8,7 @@ from nidaqmx.constants import AcquisitionType, LineGrouping with nidaqmx.Task() as task: - data: bool = [bool(i % 2) for i in range(1000)] + data = [bool(i % 2) for i in range(1000)] task.do_channels.add_do_chan("Dev1/port0/line0", line_grouping=LineGrouping.CHAN_PER_LINE) task.timing.cfg_samp_clk_timing( diff --git a/examples/playrec.py b/examples/playrec.py index cf5ead78e..f1462d93c 100644 --- a/examples/playrec.py +++ b/examples/playrec.py @@ -2,13 +2,14 @@ import numpy as np -import nidaqmx as ni +import nidaqmx +import nidaqmx.system from nidaqmx.constants import WAIT_INFINITELY def query_devices(): """Queries all the device information connected to the local system.""" - local = ni.system.System.local() + local = nidaqmx.system.System.local() for device in local.devices: print(f"Device Name: {device.name}, Product Type: {device.product_type}") print("Input channels:", [chan.name for chan in device.ai_physical_chans]) @@ -35,11 +36,11 @@ def playrec(data, samplerate, input_mapping, output_mapping): Recorded data """ - devices = ni.system.System.local().devices + devices = nidaqmx.system.System.local().devices data = np.asarray(data).T nsamples = data.shape[1] - with ni.Task() as read_task, ni.Task() as write_task: + with nidaqmx.Task() as read_task, nidaqmx.Task() as write_task: for i, o in enumerate(output_mapping): aochan = write_task.ao_channels.add_ao_voltage_chan( o, diff --git a/examples/system_properties.py b/examples/system_properties.py index 3eaa2d2b8..7bcf00c19 100644 --- a/examples/system_properties.py +++ b/examples/system_properties.py @@ -1,6 +1,6 @@ """Examples for using system properties in DAQmx.""" -import nidaqmx +import nidaqmx.system local_system = nidaqmx.system.System.local() driver_version = local_system.driver_version diff --git a/pyproject.toml b/pyproject.toml index 28bcc2d4b..f82e0ea7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,7 +158,7 @@ requires = ["poetry-core>=2.1,<3.0"] build-backend = "poetry.core.masonry.api" [tool.mypy] -files = "generated/,tests/" +files = "examples/,generated/,tests/" check_untyped_defs = true namespace_packages = true warn_redundant_casts = true @@ -178,6 +178,8 @@ module = [ "nidaqmx.*", # https://github.com/ionelmc/pytest-benchmark/issues/212 - Add type annotations "pytest_benchmark.*", + # https://github.com/adamreeve/npTDMS/issues/301 - Type Hints/Annotations + "nptdms.*", ] ignore_missing_imports = true