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 Jul 23, 2022
1 parent 8ceeb5c commit f97c39d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qcodes/instrument/instrument_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
Optional,
Sequence,
Type,
TypeVar,
Union,
cast,
)

import numpy as np
Expand All @@ -29,6 +31,8 @@

log = logging.getLogger(__name__)

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


class InstrumentBase(Metadatable, DelegateAttributes):
"""
Expand Down Expand Up @@ -85,9 +89,9 @@ def __init__(self, name: str, metadata: Optional[Mapping[Any, Any]] = None) -> N
def add_parameter(
self,
name: str,
parameter_class: Optional[Type[ParameterBase]] = None,
parameter_class: Optional[Type[TParameter]] = None,
**kwargs: Any,
) -> None:
) -> TParameter:
"""
Bind one Parameter to this instrument.
Expand Down Expand Up @@ -117,7 +121,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 @@ -145,6 +149,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 f97c39d

Please sign in to comment.