Skip to content

Commit 2cf57b4

Browse files
author
Michael Johansen
committed
Fix mypy errors and add a TODO comment.
Signed-off-by: Michael Johansen <[email protected]>
1 parent 2164b0f commit 2cf57b4

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pyright = { version = ">=1.1.400", extras = ["nodejs"] }
3030
pytest = ">=7.2"
3131
pytest-cov = ">=4.0"
3232
pytest-mock = ">=3.0"
33+
# Use an unreleased version of hightime for testing.
3334
hightime = { git = "https://github.com/ni/hightime.git" }
3435

3536
[tool.poetry.group.codegen.dependencies]

src/nipanel/converters/protobuf_types.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Classes to convert between measurement specific protobuf types and containers."""
22

33
import collections.abc
4-
import datetime as dt
54
from typing import Type, Union
65

76
import hightime as ht
@@ -22,7 +21,6 @@
2221
ExtendedPropertyDictionary,
2322
ExtendedPropertyValue,
2423
NoneScaleMode,
25-
SampleIntervalMode,
2624
Timing,
2725
)
2826
from typing_extensions import TypeAlias
@@ -107,21 +105,19 @@ def to_python_value(self, protobuf_message: DoubleAnalogWaveform) -> AnalogWavef
107105
# Timestamp
108106
pt_converter = PrecisionTimestampConverter()
109107
bin_datetime = pt_converter.to_python_value(protobuf_message.t0)
110-
timestamp = convert_datetime(dt.datetime, bin_datetime)
108+
# TODO: We shouldn't need to convert to dt.datetime here.
109+
# I'm only doing this to avoid a mypy error. This needs to be fixed.
110+
timestamp = bin_datetime._to_datetime_datetime()
111111

112112
# Sample Interval
113113
if not protobuf_message.dt:
114-
sample_interval_mode = SampleIntervalMode.NONE
115-
sample_interval = None
114+
timing = Timing.create_with_no_interval(timestamp=timestamp)
116115
else:
117-
sample_interval_mode = SampleIntervalMode.REGULAR
118116
sample_interval = ht.timedelta(seconds=protobuf_message.dt)
119-
120-
timing = Timing(
121-
sample_interval_mode=sample_interval_mode,
122-
timestamp=timestamp,
123-
sample_interval=sample_interval,
124-
)
117+
timing = Timing.create_with_regular_interval(
118+
sample_interval=sample_interval,
119+
timestamp=timestamp,
120+
)
125121

126122
extended_properties = {}
127123
for key, value in protobuf_message.attributes.items():

0 commit comments

Comments
 (0)