Add ANN002, and ANN003 rules

This commit is contained in:
Julian Stirling 2025-08-27 13:33:11 +01:00
parent 24233412af
commit d673196671
6 changed files with 11 additions and 11 deletions

View file

@ -126,7 +126,7 @@ select = [
"N", # PEP8 naming "N", # PEP8 naming
"D", # Docstring checks "D", # Docstring checks
"ERA001", # Commented out code! "ERA001", # Commented out code!
"ANN001", "ANN001", "ANN002", "ANN003",
] ]
ignore = [ ignore = [

View file

@ -2,13 +2,13 @@
from __future__ import annotations from __future__ import annotations
from typing import Optional, Callable from typing import Optional, Callable, Any
from functools import wraps from functools import wraps
from copy import copy from copy import copy
import logging
import labthings_fastapi as lt import labthings_fastapi as lt
import uvicorn import uvicorn
import logging
from uvicorn.main import Server from uvicorn.main import Server
from .serve_static_files import add_static_files from .serve_static_files import add_static_files
from .legacy_api import add_v2_endpoints from .legacy_api import add_v2_endpoints
@ -32,7 +32,7 @@ def set_shutdown_function(shutdown_function: Callable[[], None]):
original_handler = Server.handle_exit original_handler = Server.handle_exit
@wraps(Server.handle_exit) @wraps(Server.handle_exit)
def handle_exit(*args, **kwargs): def handle_exit(*args: Any, **kwargs: Any):
shutdown_function() shutdown_function()
original_handler(*args, **kwargs) original_handler(*args, **kwargs)

View file

@ -252,7 +252,7 @@ class JPEGSharpnessMonitor:
finally: finally:
self.running = False 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. """Move the stage by dz, monitoring the position over time.
This performs exactly one move. Multiple calls of this method This performs exactly one move. Multiple calls of this method
@ -268,7 +268,7 @@ class JPEGSharpnessMonitor:
self.stage_positions.append(self.stage.position) self.stage_positions.append(self.stage.position)
# Main move # 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 # Store the end time and position
self.stage_times.append(time.time()) self.stage_times.append(time.time())

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Optional from typing import Optional, Any
from types import TracebackType from types import TracebackType
from collections.abc import Mapping from collections.abc import Mapping
import time import time
@ -19,7 +19,7 @@ class DummyStage(BaseStage):
hardware attached. 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. """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 :param step_time: The time in seconds per "motor" step. The default of 0.001

View file

@ -5,7 +5,7 @@ import logging
import threading import threading
import time import time
from copy import copy from copy import copy
from typing import Iterator, Literal, Optional from typing import Iterator, Literal, Optional, Any
from types import TracebackType from types import TracebackType
from contextlib import contextmanager from contextlib import contextmanager
from collections.abc import Mapping from collections.abc import Mapping
@ -25,7 +25,7 @@ class SangaboardThing(BaseStage):
functionality is accessed by directly querying the serial interface. 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 SangaboardThing.
Initialise the "Thing", but do not initialise an underlying Initialise the "Thing", but do not initialise an underlying

View file

@ -120,7 +120,7 @@ class ErrorCapturingThread(Thread):
def _wrap_and_catch_errors( 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. """Run target function in a try-except block.