Commit daec003e authored by Linus Pithan's avatar Linus Pithan
Browse files

some more type checking in shell standard

parent 5ad70f00
......@@ -42,7 +42,8 @@ from bliss.common.protocols import CounterContainer
from bliss.common import measurementgroup
from bliss.common.soft_axis import SoftAxis
from bliss.common.counter import SoftCounter, Counter
from bliss.common.utils import ShellStr
from bliss.common.utils import ShellStr, typecheck_var_args_pattern, modify_annotations
from bliss.common.measurementgroup import MeasurementGroup
# objects given to Bliss shell user
from bliss.common.standard import mv, mvr, move
......@@ -61,6 +62,14 @@ from bliss.shell.cli import user_dialog, pt_widgets
from tabulate import tabulate
from bliss.common.types import (
_countable,
_scannable,
_scannable_or_name,
_float,
Optional,
)
__all__ = (
[
"wa",
......@@ -300,7 +309,8 @@ def wid():
print(std_wid())
def stm(*axes, read_hw=False):
# @typeguard.typechecked # type checking acually acceses all members ... does not work for 'bad' motor
def stm(*axes: _scannable_or_name, read_hw: bool = False):
"""
Displays state information of the given axes
......@@ -325,7 +335,8 @@ def stm(*axes, read_hw=False):
_print_errors_with_traceback(errors, device_type="motor")
def sta(read_hw=False):
@typeguard.typechecked
def sta(read_hw: bool = False):
"""
Return state information about all axes
......@@ -378,7 +389,8 @@ def wa(**kwargs):
print(_tabulate(table))
def wm(*axes, **kwargs):
@typeguard.typechecked
def wm(*axes: _scannable_or_name, **kwargs):
"""
Display information (position - user and dial, limits) of the given axes
......@@ -497,6 +509,8 @@ def wm(*axes, **kwargs):
print(_tabulate(table).replace("~", " "))
@modify_annotations({"args": "motor1, pos1, motor2, pos2, ..."})
@typecheck_var_args_pattern([_scannable, _float])
def umv(*args):
"""
Moves given axes to given absolute positions providing updated display of
......@@ -507,6 +521,8 @@ def umv(*args):
__umove(*args)
@modify_annotations({"args": "motor1, rel. pos1, motor2, rel. pos2, ..."})
@typecheck_var_args_pattern([_scannable, _float])
def umvr(*args):
"""
Moves given axes to given relative positions providing updated display of
......@@ -595,7 +611,8 @@ def prdef(obj_or_name):
print(__pyhighlight("".join(lines)))
def plotselect(*counters):
@typeguard.typechecked
def plotselect(*counters: _countable):
"""
Selects counters to plot and used by alignment functions (cen, peak, etc).
User-level function built on top of bliss.common.scans.plotselect()
......@@ -738,7 +755,8 @@ def clear():
os.system("clear")
def edit_mg(mg=None):
@typeguard.typechecked
def edit_mg(mg: MeasurementGroup):
"""
Edit the measurement group with a simple dialog.
mg -- a measurement group if left to None == default
......@@ -796,19 +814,22 @@ def edit_mg(mg=None):
# from bliss/scanning/scan_saving.py
def newproposal(proposal_name=None):
@typeguard.typechecked
def newproposal(proposal_name: Optional[str] = None):
"""Change the proposal name used to determine the saving path.
"""
current_session.scan_saving.newproposal(proposal_name)
def newsample(sample_name=None):
@typeguard.typechecked
def newsample(sample_name: Optional[str] = None):
"""Change the sample name used to determine the saving path.
"""
current_session.scan_saving.newsample(sample_name)
def newdataset(dataset_name=None):
@typeguard.typechecked
def newdataset(dataset_name: Optional[str] = None):
"""Change the dataset name used to determine the saving path.
"""
current_session.scan_saving.newdataset(dataset_name)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment