From 06cab8a6a4d5b9c098b02b7f55139e3661ab81a6 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Mon, 12 Jan 2026 14:56:10 +0000 Subject: [PATCH] Use type[] not Type[] in typehints, and add clarification comment. --- .../background_detect.py | 14 +++++++------- .../things/camera/__init__.py | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/openflexure_microscope_server/background_detect.py b/src/openflexure_microscope_server/background_detect.py index a7e749ba..37c08aa4 100644 --- a/src/openflexure_microscope_server/background_detect.py +++ b/src/openflexure_microscope_server/background_detect.py @@ -5,7 +5,7 @@ for analysis. Information from these images is used to detect whether an image f current camera field of view contains sample. """ -from typing import Any, Generic, Optional, Type, TypeVar +from typing import Any, Generic, Optional, TypeVar import cv2 import numpy as np @@ -61,9 +61,9 @@ class BackgroundDetectorStatus(BaseModel): class BackgroundDetectAlgorithm(Generic[SettingsType, BackgroundType]): """The base class for defining background detect algorithms.""" - background_data_model: Type[BackgroundType] + background_data_model: type[BackgroundType] """The data model of the background data. This must be set by child classes""" - settings_data_model: Type[SettingsType] + settings_data_model: type[SettingsType] """The data model of algorithm settings. This must be set by child classes""" def __init__(self) -> None: @@ -198,8 +198,8 @@ class ColourChannelDetectLUV( intuitive way. """ - background_data_model: Type[ChannelDistributions] = ChannelDistributions - settings_data_model: Type[ColourChannelDetectSettings] = ColourChannelDetectSettings + background_data_model: type[ChannelDistributions] = ChannelDistributions + settings_data_model: type[ColourChannelDetectSettings] = ColourChannelDetectSettings # These are the same as those used for ChannelDeviationLUV. More detail is # provided there. @@ -297,8 +297,8 @@ class ChannelDeviationLUV( # Note we don't use the means in this algorithm but we use the same channel # distributions model - background_data_model: Type[ChannelDistributions] = ChannelDistributions - settings_data_model: Type[ColourChannelDetectSettings] = ColourChannelDetectSettings + background_data_model: type[ChannelDistributions] = ChannelDistributions + settings_data_model: type[ColourChannelDetectSettings] = ColourChannelDetectSettings # Empirically, 0.5 seems to be approximate the standard deviation for a good image # in L and V. U appears to be about 60% of this value. U is about 65% of V when diff --git a/src/openflexure_microscope_server/things/camera/__init__.py b/src/openflexure_microscope_server/things/camera/__init__.py index 7592de1d..43869872 100644 --- a/src/openflexure_microscope_server/things/camera/__init__.py +++ b/src/openflexure_microscope_server/things/camera/__init__.py @@ -210,6 +210,9 @@ class BaseCamera(lt.Thing): :param main_resolution: the resolution to use for the main stream. :param buffer_count: number of images in the stream buffer. + + Note that the default values for both parameters should be set appropriately + for the specific camera when defining a new Camera Thing. """ raise NotImplementedError( "CameraThings must define their own start_streaming method"