diff --git a/pyproject.toml b/pyproject.toml index b1d8aaa9..58430873 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,7 +126,7 @@ select = [ "N", # PEP8 naming "D", # Docstring checks "ERA001", # Commented out code! - "ANN001", + "ANN001", "ANN002", "ANN003", ] ignore = [ diff --git a/src/openflexure_microscope_server/server/__init__.py b/src/openflexure_microscope_server/server/__init__.py index d5058fe8..e7964da3 100644 --- a/src/openflexure_microscope_server/server/__init__.py +++ b/src/openflexure_microscope_server/server/__init__.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing import Optional, Callable +from typing import Optional, Callable, Any from functools import wraps from copy import copy +import logging import labthings_fastapi as lt import uvicorn -import logging from uvicorn.main import Server from .serve_static_files import add_static_files from .legacy_api import add_v2_endpoints @@ -32,7 +32,7 @@ def set_shutdown_function(shutdown_function: Callable[[], None]): original_handler = Server.handle_exit @wraps(Server.handle_exit) - def handle_exit(*args, **kwargs): + def handle_exit(*args: Any, **kwargs: Any): shutdown_function() original_handler(*args, **kwargs) diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index e80d1e47..48c475ac 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -252,7 +252,7 @@ class JPEGSharpnessMonitor: finally: self.running = False - def focus_rel(self, dz: int, **kwargs) -> tuple[int, int]: + def focus_rel(self, dz: int, block_cancellation: int = False) -> tuple[int, int]: """Move the stage by dz, monitoring the position over time. This performs exactly one move. Multiple calls of this method @@ -268,7 +268,7 @@ class JPEGSharpnessMonitor: self.stage_positions.append(self.stage.position) # Main move - self.stage.move_relative(z=dz, **kwargs) + self.stage.move_relative(z=dz, block_cancellation=block_cancellation) # Store the end time and position self.stage_times.append(time.time()) diff --git a/src/openflexure_microscope_server/things/stage/dummy.py b/src/openflexure_microscope_server/things/stage/dummy.py index 3015b42c..45f7f38c 100644 --- a/src/openflexure_microscope_server/things/stage/dummy.py +++ b/src/openflexure_microscope_server/things/stage/dummy.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Optional +from typing import Optional, Any from types import TracebackType from collections.abc import Mapping import time @@ -19,7 +19,7 @@ class DummyStage(BaseStage): hardware attached. """ - def __init__(self, step_time: float = 0.001, **kwargs): + def __init__(self, step_time: float = 0.001, **kwargs: Any): """Initialise the Dummy stage, setting the step_time to adjust the speed. :param step_time: The time in seconds per "motor" step. The default of 0.001 diff --git a/src/openflexure_microscope_server/things/stage/sangaboard.py b/src/openflexure_microscope_server/things/stage/sangaboard.py index 8fea6684..05fb55a9 100644 --- a/src/openflexure_microscope_server/things/stage/sangaboard.py +++ b/src/openflexure_microscope_server/things/stage/sangaboard.py @@ -5,7 +5,7 @@ import logging import threading import time from copy import copy -from typing import Iterator, Literal, Optional +from typing import Iterator, Literal, Optional, Any from types import TracebackType from contextlib import contextmanager from collections.abc import Mapping @@ -25,7 +25,7 @@ class SangaboardThing(BaseStage): functionality is accessed by directly querying the serial interface. """ - def __init__(self, port: str = None, **kwargs): + def __init__(self, port: str = None, **kwargs: Any): """Initialise SangaboardThing. Initialise the "Thing", but do not initialise an underlying diff --git a/src/openflexure_microscope_server/utilities.py b/src/openflexure_microscope_server/utilities.py index 5975ed1e..065b2683 100644 --- a/src/openflexure_microscope_server/utilities.py +++ b/src/openflexure_microscope_server/utilities.py @@ -120,7 +120,7 @@ class ErrorCapturingThread(Thread): def _wrap_and_catch_errors( - target: Callable[..., Any], error_buffer: list, *args, **kwargs + target: Callable[..., Any], error_buffer: list, *args: Any, **kwargs: Any ): """Run target function in a try-except block.