Skip to content

Commit

Permalink
Return created parameter from add_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Sep 22, 2022
1 parent 220df47 commit 1881499
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions qcodes/instrument/instrument_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import warnings
from collections.abc import Callable, Mapping, Sequence
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Type, TypeVar, cast

import numpy as np

Expand All @@ -21,6 +21,8 @@

log = logging.getLogger(__name__)

TParameter = TypeVar("TParameter", bound=ParameterBase)


class InstrumentBase(Metadatable, DelegateAttributes):
"""
Expand Down Expand Up @@ -98,9 +100,9 @@ def label(self, label: str) -> None:
def add_parameter(
self,
name: str,
parameter_class: type[ParameterBase] | None = None,
parameter_class: type[TParameter] | None = None,
**kwargs: Any,
) -> None:
) -> TParameter:
"""
Bind one Parameter to this instrument.
Expand Down Expand Up @@ -130,7 +132,7 @@ def add_parameter(
one.
"""
if parameter_class is None:
parameter_class = Parameter
parameter_class = cast(Type[TParameter], Parameter)

if "bind_to_instrument" not in kwargs.keys():
kwargs["bind_to_instrument"] = True
Expand Down Expand Up @@ -158,6 +160,7 @@ def add_parameter(
QCoDeSDeprecationWarning,
)
self.parameters[name] = param
return param

def add_function(self, name: str, **kwargs: Any) -> None:
"""
Expand Down

0 comments on commit 1881499

Please sign in to comment.