From e5540dd624e9e5b5168841794c950f7e6dc641d8 Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Wed, 20 Aug 2025 14:28:54 -0500 Subject: [PATCH 1/2] Fix some comments and docstrings Signed-off-by: Michael Johansen --- src/nipanel/_panel_value_accessor.py | 2 +- src/nipanel/converters/protobuf_types.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/nipanel/_panel_value_accessor.py b/src/nipanel/_panel_value_accessor.py index 9404a20..600d40e 100644 --- a/src/nipanel/_panel_value_accessor.py +++ b/src/nipanel/_panel_value_accessor.py @@ -69,7 +69,7 @@ def get_value(self, value_id: str, default_value: _T | None = None) -> _T | obje Returns: The value, or the default value if not set. The returned value will - be the same as default_value, if one was provided. + have the same type as default_value, if one was provided. Raises: KeyError: If the value is not set and no default value is provided diff --git a/src/nipanel/converters/protobuf_types.py b/src/nipanel/converters/protobuf_types.py index 530487b..ba74273 100644 --- a/src/nipanel/converters/protobuf_types.py +++ b/src/nipanel/converters/protobuf_types.py @@ -405,7 +405,13 @@ def to_python_value( class HTDateTimeConverter(Converter[ht.datetime, precision_timestamp_pb2.PrecisionTimestamp]): - """A converter for hightime.datetime objects.""" + """A converter for hightime.datetime objects. + + Note: The nipanel package will always convert PrecisionTimestamp messages to + bintime.DateTime objects using BTDateTimeConverter. To use hightime.datetime + values in a panel, you must pass a hightime.datetime value for the default_value + parameter of the get_value() method on the panel. + """ @property def python_type(self) -> type: @@ -419,14 +425,12 @@ def protobuf_message(self) -> Type[precision_timestamp_pb2.PrecisionTimestamp]: @property def protobuf_typename(self) -> str: - """The protobuf name for the type. - - Override the base class here because there can only be one converter that - converts ``PrecisionTimestamp`` objects. Since there are two converters that convert - to ``PrecisionTimestamp``, we have to choose one to handle conversion from protobuf. - For the purposes of nipanel, we'll convert ``PrecisionTimestamp`` messages to - bintime.DateTime. See ``BTDateTimeConverter``. - """ + """The protobuf name for the type.""" + # Override the base class here because there can only be one converter that + # converts PrecisionTimestamp objects. Since there are two converters that convert + # to PrecisionTimestamp, we have to choose one to handle conversion from protobuf. + # For the purposes of nipanel, we'll convert PrecisionTimestamp messages to + # bintime.DateTime. See BTDateTimeConverter. return "PrecisionTimestamp_Placeholder" def to_protobuf_message( From 94fd6f9cb7d9a9d39c0d53a483b8335ca3d6847e Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Wed, 20 Aug 2025 15:06:30 -0500 Subject: [PATCH 2/2] Use rest syntax for the docstring note. Signed-off-by: Michael Johansen --- src/nipanel/converters/protobuf_types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nipanel/converters/protobuf_types.py b/src/nipanel/converters/protobuf_types.py index ba74273..c92cd2f 100644 --- a/src/nipanel/converters/protobuf_types.py +++ b/src/nipanel/converters/protobuf_types.py @@ -407,10 +407,10 @@ def to_python_value( class HTDateTimeConverter(Converter[ht.datetime, precision_timestamp_pb2.PrecisionTimestamp]): """A converter for hightime.datetime objects. - Note: The nipanel package will always convert PrecisionTimestamp messages to - bintime.DateTime objects using BTDateTimeConverter. To use hightime.datetime - values in a panel, you must pass a hightime.datetime value for the default_value - parameter of the get_value() method on the panel. + .. note:: The nipanel package will always convert PrecisionTimestamp messages to + bintime.DateTime objects using BTDateTimeConverter. To use hightime.datetime + values in a panel, you must pass a hightime.datetime value for the default_value + parameter of the get_value() method on the panel. """ @property