Skip to content

Commit 53841c1

Browse files
fix some types
1 parent 73061f1 commit 53841c1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pioreactor/actions/od_calibration.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from pioreactor.whoami import is_testing_env
4040

4141

42-
4342
def green(string):
4443
return style(string, fg="green")
4544

@@ -102,12 +101,14 @@ def get_metadata_from_user() -> tuple[pt.OD600, pt.OD600, pt.mL, pt.PdAngle, pt.
102101
)
103102

104103
while minimum_od600 >= initial_od600:
105-
minimum_od600 = prompt(
106-
"The minimum OD600 measurement must be less than the initial OD600 culture measurement",
107-
type=click.FloatRange(min=0, max=initial_od600, clamp=False),
104+
minimum_od600 = cast(
105+
pt.OD600,
106+
prompt(
107+
"The minimum OD600 measurement must be less than the initial OD600 culture measurement",
108+
type=click.FloatRange(min=0, max=initial_od600, clamp=False),
109+
),
108110
)
109111

110-
assert isinstance(minimum_od600, )
111112
if minimum_od600 == 0:
112113
minimum_od600 = 0.01
113114

@@ -130,8 +131,7 @@ def get_metadata_from_user() -> tuple[pt.OD600, pt.OD600, pt.mL, pt.PdAngle, pt.
130131
# technically it's not required? we just need a specific PD channel to calibrate from.
131132

132133
ref_channel = config["od_config.photodiode_channel_reverse"]["REF"]
133-
signal_channel = "1" if ref_channel == "2" else "2"
134-
#assert isinstance(signal_channel, pt.PdChannel)
134+
signal_channel = cast(pt.PdChannel, "1" if ref_channel == "2" else "2")
135135

136136
confirm(
137137
green(
@@ -140,8 +140,7 @@ def get_metadata_from_user() -> tuple[pt.OD600, pt.OD600, pt.mL, pt.PdAngle, pt.
140140
abort=True,
141141
default=True,
142142
)
143-
angle = config["od_config.photodiode_channel"][signal_channel]
144-
#assert isinstance(angle, pt.PdAngle)
143+
angle = cast(pt.PdAngle, config["od_config.photodiode_channel"][signal_channel])
145144
return initial_od600, minimum_od600, dilution_amount, angle, signal_channel
146145

147146

@@ -460,7 +459,7 @@ def save_results(
460459
return data_blob
461460

462461

463-
def get_data_from_data_file(data_file: str) -> tuple[str, str, list[float], list[float]]:
462+
def get_data_from_data_file(data_file: str) -> tuple[pt.PdChannel, pt.PdAngle, list[float], list[float]]:
464463
import json
465464

466465
click.echo(f"Pulling data from {data_file}...")

pioreactor/pubsub.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Optional
1212

1313
from paho.mqtt.client import Client as PahoClient
14-
from paho.mqtt.client import ssl
1514

1615
from pioreactor.config import config
1716
from pioreactor.config import mqtt_address
@@ -108,6 +107,8 @@ def default_on_connect(client: Client, userdata, flags, rc: int, properties=None
108107
config.get("mqtt", "password", fallback="raspberry"),
109108
)
110109
if tls:
110+
import ssl
111+
111112
client.tls_set(tls_version=ssl.PROTOCOL_TLS)
112113

113114
if on_connect:
@@ -166,8 +167,8 @@ def publish(topic: str, message, retries: int = 3, **mqtt_kwargs) -> None:
166167

167168
else:
168169
logger = create_logger("pubsub.publish", to_mqtt=False)
169-
logger.error(f"Unable to connect to MQTT.")
170-
raise ConnectionRefusedError(f"Unable to connect to MQTT.")
170+
logger.error("Unable to connect to MQTT.")
171+
raise ConnectionRefusedError("Unable to connect to MQTT.")
171172

172173

173174
def subscribe(

0 commit comments

Comments
 (0)