Skip to content

Commit

Permalink
Improved typing
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Sep 13, 2024
1 parent e879beb commit b34d14e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Next version

### ⚙️ Engineering

* Improved typing.


## 0.3.3 - September 12, 2024

### 🚀 New
Expand Down
4 changes: 2 additions & 2 deletions src/lvmopstools/devices/ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IonPumpDict(TypedDict):
on: bool | None


async def read_ion_pumps(cameras: list[str] | None = None):
async def read_ion_pumps(cameras: list[str] | None = None) -> dict[str, IonPumpDict]:
"""Reads the signal and on/off status from an ion pump.
Parameters
Expand All @@ -87,7 +87,7 @@ async def read_ion_pumps(cameras: list[str] | None = None):

ion_config: list[dict] = config["devices.ion"]

results: dict[str, dict] = {}
results: dict[str, IonPumpDict] = {}
tasks: list[asyncio.Task] = []

for ion_controller in ion_config:
Expand Down
2 changes: 1 addition & 1 deletion src/lvmopstools/devices/nps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NPSStatus(TypedDict):


@Retrier(max_attempts=3, delay=1)
async def read_nps():
async def read_nps() -> dict[str, NPSStatus]:
"""Returns the status of all NPS."""

actors = ["lvmnps.sp1", "lvmnps.sp2", "lvmnps.sp3", "lvmnps.calib"]
Expand Down
12 changes: 7 additions & 5 deletions src/lvmopstools/devices/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"spectrograph_temperatures",
"spectrograph_pressures",
"spectrograph_mechanics",
"exposure_etr",
"spectrogaph_status",
"exposure_etr",
]


Expand All @@ -36,7 +36,7 @@
SpecToStatus = dict[Spectrographs, SpecStatus]


def spectrograph_temperature_label(camera: str, sensor: str = "ccd"):
def spectrograph_temperature_label(camera: str, sensor: str = "ccd") -> str:
"""Returns the archon label associated with a temperature sensor."""

if sensor == "ccd":
Expand All @@ -55,11 +55,13 @@ def spectrograph_temperature_label(camera: str, sensor: str = "ccd"):
elif camera == "z":
return "mod12/tempb"

raise ValueError(f"Invalid camera {camera!r} or sensor {sensor!r}.")


async def spectrograph_temperatures(
spec: Spectrographs | None = None,
ignore_errors: bool = True,
):
) -> dict[str, float | None]:
"""Returns a dictionary of spectrograph temperatures.
Parameters
Expand Down Expand Up @@ -141,7 +143,7 @@ async def spectrograph_temperatures(
async def spectrograph_pressures(
spec: Spectrographs | None = None,
ignore_errors: bool = True,
):
) -> dict[str, float | None]:
"""Returns a dictionary of spectrograph pressures.
Parameters
Expand Down Expand Up @@ -212,7 +214,7 @@ async def spectrograph_pressures(
async def spectrograph_mechanics(
spec: Spectrographs | None = None,
ignore_errors: bool = True,
):
) -> dict[str, str | None]:
"""Returns a dictionary of spectrograph shutter and hartmann door status.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b34d14e

Please sign in to comment.