Skip to content

Commit 604a127

Browse files
reduncant casts
1 parent 929232a commit 604a127

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

core/pioreactor/background_jobs/od_reading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ def pop_reference_reading(self, raw_readings: RawPDReadings) -> tuple[pt.Voltage
687687
return ref_reading, raw_readings
688688

689689
def transform(self, pd_reading: pt.Voltage) -> pt.OD:
690-
return cast(pt.OD, pd_reading)
690+
return pd_reading
691691

692692

693693
class PhotodiodeIrLedReferenceTrackerStaticInit(IrLedReferenceTracker):

core/pioreactor/calibrations/protocols/od_fusion_standards.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _channel_angle_map_from_config() -> dict[pt.PdChannel, pt.PdAngle]:
6868
def _aggregate_angles(readings: structs.ODReadings) -> dict[pt.PdAngle, float]:
6969
by_angle: dict[pt.PdAngle, list[float]] = {}
7070
for reading in readings.ods.values():
71-
angle = cast(pt.PdAngle, reading.angle)
71+
angle = reading.angle
7272
if angle not in FUSION_ANGLES:
7373
continue
7474
by_angle.setdefault(angle, []).append(float(reading.od))

core/pioreactor/calibrations/protocols/od_standards.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,15 @@ def get_valid_od_devices_for_this_unit() -> list[pt.ODCalibrationDevices]:
615615
for _, angle in pd_channels.items():
616616
if angle in (None, "", REF_keyword):
617617
continue
618-
device = f"od{angle}"
619-
if device in pt.OD_DEVICES and device not in valid_devices:
620-
valid_devices.append(cast(pt.ODCalibrationDevices, device))
618+
if angle == "45" and "od45" not in valid_devices:
619+
valid_devices.append("od45")
620+
elif angle == "90" and "od90" not in valid_devices:
621+
valid_devices.append("od90")
622+
elif angle == "135" and "od135" not in valid_devices:
623+
valid_devices.append("od135")
621624

622625
if len(valid_devices) >= 2:
623-
valid_devices.append(cast(pt.ODCalibrationDevices, "od"))
626+
valid_devices.append("od")
624627

625628
return valid_devices
626629

core/pioreactor/hardware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ def get_layered_mod_config_for_model(mod: str, model_name: str, model_version: s
132132
def determine_gpiochip() -> pt.GpioChip:
133133
"""Return the GPIO chip index for the current Raspberry Pi."""
134134

135-
return cast(pt.GpioChip, 4 if rpi_version_info.startswith("Raspberry Pi 5") else 0)
135+
if rpi_version_info.startswith("Raspberry Pi 5"):
136+
return 4
137+
return 0
136138

137139

138140
@cache

core/pioreactor/structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ class SimplePeristalticPumpCalibration(CalibrationBase, kw_only=True, tag="simpl
490490
y: str = "Volume"
491491

492492
def ml_to_duration(self, ml: pt.mL) -> pt.Seconds:
493-
return t.cast(pt.Seconds, self.y_to_x(ml))
493+
return self.y_to_x(ml)
494494

495495
def duration_to_ml(self, duration: pt.Seconds) -> pt.mL:
496-
return t.cast(pt.mL, self.x_to_y(duration))
496+
return self.x_to_y(duration)
497497

498498

499499
class SimpleStirringCalibration(CalibrationBase, kw_only=True, tag="simple_stirring"):

core/pioreactor/web/unit_api.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from msgspec import to_builtins
2828
from msgspec.yaml import decode as yaml_decode
2929
from pioreactor import structs
30-
from pioreactor import types as pt
3130
from pioreactor import whoami
3231
from pioreactor.bioreactor import get_all_bioreactor_values
3332
from pioreactor.bioreactor import get_bioreactor_value
@@ -37,7 +36,6 @@
3736
from pioreactor.config import get_leader_hostname
3837
from pioreactor.estimators import ESTIMATOR_PATH
3938
from pioreactor.models import get_registered_models
40-
from pioreactor.pubsub import Client
4139
from pioreactor.pubsub import create_client
4240
from pioreactor.structs import CalibrationBase
4341
from pioreactor.structs import subclass_union
@@ -787,9 +785,7 @@ def update_bioreactor_values(experiment: str) -> ResponseReturnValue:
787785
try:
788786
with create_client() as mqtt_client:
789787
for variable_name, value in values.items():
790-
set_and_publish_bioreactor_value(
791-
cast(Client, mqtt_client), HOSTNAME, experiment, variable_name, value
792-
)
788+
set_and_publish_bioreactor_value(mqtt_client, HOSTNAME, experiment, variable_name, value)
793789
except Exception as e:
794790
publish_to_error_log(str(e), "update_bioreactor_values")
795791
abort_with(400, str(e))

0 commit comments

Comments
 (0)