diff --git a/.github/package.json b/.github/package.json index e02d4b44d4b..557d4c89208 100644 --- a/.github/package.json +++ b/.github/package.json @@ -1,5 +1,5 @@ { "devDependencies": { - "pyright": "1.1.391" + "pyright": "1.1.392" } } diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4daab6d27c8..eb167ecc0cc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit @@ -39,12 +39,12 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/init@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/autobuild@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/analyze@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 21a469b132c..922916c5101 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 1065fe4d704..f04f3db6b58 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -43,7 +43,7 @@ jobs: SPHINX_OPTS: "-v -j 2" steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -63,7 +63,7 @@ jobs: sudo apt install pandoc if: runner.os == 'Linux' - name: Install pandoc on windows - uses: Wandalen/wretry.action@ffdd254f4eaf1562b8a2c66aeaa37f1ff2231179 # v3.7.3 + uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0 with: action: crazy-max/ghaction-chocolatey@v1.6.0 with: | @@ -98,7 +98,7 @@ jobs: ./make.bat html if: runner.os == 'Windows' - name: Upload build docs - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: name: docs_${{ matrix.python-version }}_${{ matrix.os }} path: ${{ github.workspace }}/docs/_build/html @@ -113,7 +113,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f3f4ed4933f..ac7370bb8fe 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 603cc369c29..d06f1276e05 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -52,7 +52,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index edd2d6598dc..59f6832663a 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit @@ -63,7 +63,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: name: SARIF file path: results.sarif @@ -71,6 +71,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1 with: sarif_file: results.sarif diff --git a/.github/workflows/upload_to_pypi.yaml b/.github/workflows/upload_to_pypi.yaml index b29e1424d09..5dc4e6de2f4 100644 --- a/.github/workflows/upload_to_pypi.yaml +++ b/.github/workflows/upload_to_pypi.yaml @@ -17,7 +17,7 @@ jobs: id-token: write steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit diff --git a/docs/changes/newsfragments/6722.improved b/docs/changes/newsfragments/6722.improved new file mode 100644 index 00000000000..bb853b0d9a7 --- /dev/null +++ b/docs/changes/newsfragments/6722.improved @@ -0,0 +1,3 @@ +When passing ``bind_to_instrument=False`` to ``InstrumentBase.add_parameter`` a warning that +recommends not doing this is now raised suggesting a better alternative. +This replaces an existing inconsistent warning which was misleading. diff --git a/requirements.txt b/requirements.txt index d03f65b70f5..48570c6c5d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,7 +37,7 @@ click==8.1.8 # via # dask # towncrier -cloudpickle==3.1.0 +cloudpickle==3.1.1 # via dask colorama==0.4.6 # via @@ -102,7 +102,7 @@ h5py==3.12.1 # qcodes-loop hickle==5.0.3 # via qcodes-loop -hypothesis==6.123.7 +hypothesis==6.123.17 # via qcodes (pyproject.toml) idna==3.10 # via requests @@ -169,7 +169,7 @@ kiwisolver==1.4.8 # via matplotlib lazy-loader==0.4 # via qcodes-loop -libcst==1.5.1 +libcst==1.6.0 # via qcodes (pyproject.toml) locket==1.0.0 # via partd @@ -302,7 +302,7 @@ pytest==8.3.4 # pytest-mock # pytest-rerunfailures # pytest-xdist -pytest-asyncio==0.25.1 +pytest-asyncio==0.25.2 # via qcodes (pyproject.toml) pytest-cov==6.0.0 # via qcodes (pyproject.toml) @@ -361,9 +361,9 @@ ruamel-yaml-clib==0.2.12 # via ruamel-yaml schema==0.7.7 # via broadbean -scipy==1.15.0 +scipy==1.15.1 # via qcodes (pyproject.toml) -setuptools==75.7.0 +setuptools==75.8.0 # via incremental six==1.17.0 # via @@ -457,7 +457,7 @@ types-pywin32==308.0.0.20241221 # via qcodes (pyproject.toml) types-requests==2.32.0.20241016 # via qcodes (pyproject.toml) -types-setuptools==75.6.0.20241223 +types-setuptools==75.8.0.20250110 # via qcodes (pyproject.toml) types-tabulate==0.9.0.20241207 # via qcodes (pyproject.toml) @@ -502,12 +502,12 @@ websockets==14.1 # qcodes widgetsnbextension==4.0.13 # via ipywidgets -wrapt==1.17.0 +wrapt==1.17.2 # via # qcodes (pyproject.toml) # deprecated # qcodes -xarray==2025.1.0 +xarray==2025.1.1 # via # qcodes (pyproject.toml) # cf-xarray diff --git a/src/qcodes/instrument/instrument_base.py b/src/qcodes/instrument/instrument_base.py index 55932c9a4dd..aaf0261b9db 100644 --- a/src/qcodes/instrument/instrument_base.py +++ b/src/qcodes/instrument/instrument_base.py @@ -166,6 +166,16 @@ def add_parameter( if "bind_to_instrument" not in kwargs.keys(): kwargs["bind_to_instrument"] = True + bind_to_instrument = kwargs["bind_to_instrument"] + + if bind_to_instrument is False: + warnings.warn( + f"Parameter {name} passed to `add_parameter` " + "on instrument {self.full_name} with `bind_to_instrument=False`. " + "This is not recommended as it results in inconsistent behavior. " + "To disable snapshotting of the parameter set `snapshot_exclude=True`." + ) + try: param = parameter_class(name=name, instrument=self, **kwargs) except TypeError: @@ -180,7 +190,7 @@ def add_parameter( param = parameter_class(name=name, instrument=self, **kwargs) existing_parameter = self.parameters.get(name, None) - if not existing_parameter: + if not existing_parameter and bind_to_instrument: warnings.warn( f"Parameter {name} did not correctly register itself on instrument" f" {self.name}. Please check that `instrument` argument is passed " diff --git a/tests/parameter/test_parameter_registration.py b/tests/parameter/test_parameter_registration.py index af1309e9ef9..b70fa44cf63 100644 --- a/tests/parameter/test_parameter_registration.py +++ b/tests/parameter/test_parameter_registration.py @@ -88,3 +88,16 @@ def test_parameter_registration_with_non_kwargs_passing_parameter( # (bind_to_instrument specifically) # to the baseclass it will still be registered on the instr assert "brokenparameter2" in dummy_attr_instr.parameters.keys() + + +def test_parameter_registration_bind_to_instrument_false( + dummy_attr_instr: DummyAttrInstrument, +) -> None: + with pytest.warns(UserWarning, match="passed to `add_parameter`"): + dummy_attr_instr.add_parameter( + name="non_binding_parameter", + set_cmd=None, + get_cmd=None, + bind_to_instrument=False, + ) + assert "non_binding_parameter" not in dummy_attr_instr.parameters.keys()