Skip to content

Commit

Permalink
Merge pull request #412 from DiamondLightSource/411_drop_py_3_9
Browse files Browse the repository at this point in the history
Drop python 3.9 support
  • Loading branch information
d-perl authored Apr 5, 2024
2 parents 871e052 + b93f309 commit be80792
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from argparse import ArgumentParser
from pathlib import Path
from subprocess import CalledProcessError, check_output
from typing import List, Optional
from typing import List


def report_output(stdout: bytes, label: str) -> List[str]:
Expand All @@ -24,7 +24,7 @@ def get_sorted_tags_list() -> List[str]:
return report_output(stdout, "Tags list")


def get_versions(ref: str, add: Optional[str], remove: Optional[str]) -> List[str]:
def get_versions(ref: str, add: str | None, remove: str | None) -> List[str]:
"""Generate the file containing the list of all GitHub Pages builds."""
# Get the directories (i.e. builds) from the GitHub Pages branch
try:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.10", "3.11"]
python: ["3.11"]
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
- os: "ubuntu-latest"
python: "3.9"
python: "3.10"
install: ".[dev]"

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/beamlines/beamline_parameters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional, Tuple, cast
from typing import Any, Tuple, cast

from dodal.log import LOGGER
from dodal.utils import get_beamline_name
Expand Down Expand Up @@ -87,7 +87,7 @@ def parse_list(cls, value: str):
return list_output


def get_beamline_parameters(beamline_param_path: Optional[str] = None):
def get_beamline_parameters(beamline_param_path: str | None = None):
"""Loads the beamline parameters from the specified path, or according to the
environment variable if none is given"""
if not beamline_param_path:
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/beamlines/beamline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

ACTIVE_DEVICES: Dict[str, AnyDevice] = {}
BL = ""
DIRECTORY_PROVIDER: Optional[DirectoryProvider] = None
DIRECTORY_PROVIDER: DirectoryProvider | None = None


def set_beamline(beamline: str):
Expand Down Expand Up @@ -96,7 +96,7 @@ def device_instantiation(
Returns:
The instance of the device.
"""
already_existing_device: Optional[AnyDevice] = ACTIVE_DEVICES.get(name)
already_existing_device: AnyDevice | None = ACTIVE_DEVICES.get(name)
if fake:
device_factory = cast(Callable[..., T], make_fake_device(device_factory))
if already_existing_device is None:
Expand Down
6 changes: 2 additions & 4 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from ophyd_async.panda import PandA

from dodal.beamlines.beamline_utils import device_instantiation
Expand Down Expand Up @@ -101,7 +99,7 @@ def vfm_mirror_voltages(
def aperture_scatterguard(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
aperture_positions: Optional[AperturePositions] = None,
aperture_positions: AperturePositions | None = None,
) -> ApertureScatterguard:
"""Get the i03 aperture and scatterguard device, instantiate it if it hasn't already
been. If this is called when already instantiated in i03, it will return the existing
Expand Down Expand Up @@ -157,7 +155,7 @@ def detector_motion(
def eiger(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
params: Optional[DetectorParams] = None,
params: DetectorParams | None = None,
) -> EigerDetector:
"""Get the i03 Eiger device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand Down
6 changes: 2 additions & 4 deletions src/dodal/beamlines/i04.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from dodal.beamlines.beamline_utils import device_instantiation
from dodal.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.aperturescatterguard import AperturePositions, ApertureScatterguard
Expand Down Expand Up @@ -215,7 +213,7 @@ def backlight(
def aperture_scatterguard(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
aperture_positions: Optional[AperturePositions] = None,
aperture_positions: AperturePositions | None = None,
) -> ApertureScatterguard:
"""Get the i04 aperture and scatterguard device, instantiate it if it hasn't already
been. If this is called when already instantiated in i04, it will return the existing
Expand All @@ -240,7 +238,7 @@ def load_positions(a_s: ApertureScatterguard):
def eiger(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
params: Optional[DetectorParams] = None,
params: DetectorParams | None = None,
) -> EigerDetector:
"""Get the i04 Eiger device, instantiate it if it hasn't already been.
If this is called when already instantiated in i04, it will return the existing object.
Expand Down
4 changes: 1 addition & 3 deletions src/dodal/beamlines/i04_1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from dodal.beamlines.beamline_utils import device_instantiation
from dodal.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.backlight import Backlight
Expand Down Expand Up @@ -45,7 +43,7 @@ def backlight(
def eiger(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
params: Optional[DetectorParams] = None,
params: DetectorParams | None = None,
) -> EigerDetector:
"""Get the i04_1 Eiger device, instantiate it if it hasn't already been.
If this is called when already instantiated in i04_1, it will return the existing object.
Expand Down
4 changes: 1 addition & 3 deletions src/dodal/beamlines/i24.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from dodal.beamlines.beamline_utils import BL, device_instantiation
from dodal.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.detector import DetectorParams
Expand Down Expand Up @@ -56,7 +54,7 @@ def detector_motion(
def eiger(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
params: Optional[DetectorParams] = None,
params: DetectorParams | None = None,
) -> EigerDetector:
"""Get the i24 Eiger device, instantiate it if it hasn't already been.
If this is called when already instantiated, it will return the existing object.
Expand Down
8 changes: 4 additions & 4 deletions src/dodal/devices/aperturescatterguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import namedtuple
from dataclasses import dataclass
from functools import reduce
from typing import List, Optional, Sequence
from typing import List, Sequence

from ophyd import Component as Cpt
from ophyd import SignalRO
Expand Down Expand Up @@ -35,12 +35,12 @@ class InvalidApertureMove(Exception):
class SingleAperturePosition:
name: str
GDA_name: str
radius_microns: Optional[float]
radius_microns: float | None
location: ApertureFiveDimensionalLocation


def position_from_params(
name: str, GDA_name: str, radius_microns: Optional[float], params: dict
name: str, GDA_name: str, radius_microns: float | None, params: dict
) -> SingleAperturePosition:
return SingleAperturePosition(
name,
Expand Down Expand Up @@ -86,7 +86,7 @@ def as_list(self) -> List[SingleAperturePosition]:
class ApertureScatterguard(InfoLoggingDevice):
aperture = Cpt(Aperture, "-MO-MAPT-01:")
scatterguard = Cpt(Scatterguard, "-MO-SCAT-01:")
aperture_positions: Optional[AperturePositions] = None
aperture_positions: AperturePositions | None = None
TOLERANCE_STEPS = 3 # Number of MRES steps

class SelectedAperture(SignalRO):
Expand Down
4 changes: 1 addition & 3 deletions src/dodal/devices/attenuator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from ophyd import Component, Device, EpicsSignal, EpicsSignalRO, Kind
from ophyd.status import Status, SubscriptionStatus

Expand Down Expand Up @@ -78,7 +76,7 @@ def set(self, transmission: float) -> SubscriptionStatus:
change = Component(EpicsSignal, "FANOUT")
actual_transmission = Component(EpicsSignal, "MATCH", kind=Kind.hinted)

detector_params: Optional[DetectorParams] = None
detector_params: DetectorParams | None = None

def get_calculated_filter_state_list(self) -> list[EpicsSignalRO]:
return [
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/devices/detector/det_dim_constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Dict, Generic, TypeVar, Union
from typing import Dict, Generic, TypeVar

from pydantic.dataclasses import dataclass

T = TypeVar("T", bound=Union[float, int])
T = TypeVar("T", bound=float | int)


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/devices/detector/detector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum, auto
from typing import Any, Optional, Tuple
from typing import Any, Tuple

from pydantic import BaseModel, root_validator, validator

Expand Down Expand Up @@ -28,7 +28,7 @@ class DetectorParams(BaseModel):
"""Holds parameters for the detector. Provides access to a list of Dectris detector
sizes and a converter for distance to beam centre."""

expected_energy_ev: Optional[float] = None
expected_energy_ev: float | None = None
exposure_time: float
directory: str
prefix: str
Expand Down
3 changes: 1 addition & 2 deletions src/dodal/devices/eiger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from enum import Enum
from typing import Optional

from ophyd import Component, Device, EpicsSignalRO, Signal
from ophyd.areadetector.cam import EigerDetectorCam
Expand Down Expand Up @@ -40,7 +39,7 @@ def set(self, value, *, timeout=None, settle_time=None, **kwargs):

filewriters_finished: SubscriptionStatus

detector_params: Optional[DetectorParams] = None
detector_params: DetectorParams | None = None

arming_status = Status()
arming_status.set_finished()
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/devices/motors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import List, Tuple, Union
from typing import List, Tuple

import numpy as np
from ophyd import Component, Device, EpicsMotor
Expand Down Expand Up @@ -41,7 +41,7 @@ class XYZLimitBundle:
z: MotorLimitHelper

def position_valid(
self, position: Union[np.ndarray, List[float], Tuple[float, float, float]]
self, position: np.ndarray | List[float] | Tuple[float, float, float]
):
if len(position) != 3:
raise ValueError(
Expand Down
3 changes: 1 addition & 2 deletions src/dodal/devices/oav/pin_image_recognition/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import time
from typing import Optional

import numpy as np
from numpy.typing import NDArray
Expand All @@ -22,7 +21,7 @@
from dodal.devices.ophyd_async_utils import create_soft_signal_r, create_soft_signal_rw
from dodal.log import LOGGER

Tip = tuple[Optional[int], Optional[int]]
Tip = tuple[int | None, int | None]


class InvalidPinException(Exception):
Expand Down
6 changes: 3 additions & 3 deletions src/dodal/devices/oav/pin_image_recognition/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Callable, Final, Optional, Tuple
from typing import Callable, Final, Tuple

import cv2
import numpy as np
Expand Down Expand Up @@ -97,8 +97,8 @@ class SampleLocation:
Holder type for results from sample detection.
"""

tip_x: Optional[int]
tip_y: Optional[int]
tip_x: int | None
tip_y: int | None
edge_top: np.ndarray
edge_bottom: np.ndarray

Expand Down
3 changes: 1 addition & 2 deletions src/dodal/devices/sample_shutter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from enum import Enum
from typing import Union

from ophyd import Component, Device, EpicsSignal, EpicsSignalRO

Expand All @@ -17,7 +16,7 @@ class SampleShutter(Device):
pos = Component(EpicsSignal, "CTRL2")
pos_rbv = Component(EpicsSignalRO, "STA")

def set(self, open_val: Union[int, OpenState]):
def set(self, open_val: int | OpenState):
if isinstance(open_val, OpenState):
open_val = open_val.value
sp_status = self.pos.set(open_val)
Expand Down
8 changes: 4 additions & 4 deletions src/dodal/devices/status.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Any, TypeVar, Union
from typing import Any, TypeVar

from ophyd.status import SubscriptionStatus

T = TypeVar("T")


def await_value(
subscribable: Any, expected_value: T, timeout: Union[None, int] = None
subscribable: Any, expected_value: T, timeout: None | int = None
) -> SubscriptionStatus:
def value_is(value, **_):
return value == expected_value
Expand All @@ -15,7 +15,7 @@ def value_is(value, **_):


def await_value_in_list(
subscribable: Any, expected_value: list, timeout: Union[None, int] = None
subscribable: Any, expected_value: list, timeout: None | int = None
) -> SubscriptionStatus:
"""Returns a status which is completed when the subscriptable contains a value
within the expected_value list"""
Expand All @@ -33,7 +33,7 @@ def await_approx_value(
subscribable: Any,
expected_value: T,
deadband: float = 1e-09,
timeout: Union[None, int] = None,
timeout: None | int = None,
) -> SubscriptionStatus:
def value_is_approx(value, **_):
return abs(value - expected_value) <= deadband
Expand Down
6 changes: 3 additions & 3 deletions src/dodal/devices/util/epics_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import partial
from typing import Callable, Optional
from typing import Callable

from ophyd import Component, Device, EpicsSignal
from ophyd.status import Status, StatusBase
Expand All @@ -25,7 +25,7 @@ def epics_signal_put_wait(pv_name: str, wait: float = 3.0) -> Component[EpicsSig
def run_functions_without_blocking(
functions_to_chain: list[Callable[[], StatusBase]],
timeout: float = 60.0,
associated_obj: Optional[Device] = None,
associated_obj: Device | None = None,
) -> Status:
"""Creates and initiates an asynchronous chaining of functions which return a status
Expand All @@ -37,7 +37,7 @@ def run_functions_without_blocking(
Args:
functions_to_chain( list(function - > StatusBase) ): A list of functions which each
return a status object
associated_obj (Optional[Device]): The device that should be associated with the
associated_obj (Device | None): The device that should be associated with the
returned status
Returns:
Expand Down
3 changes: 1 addition & 2 deletions src/dodal/devices/zocalo/zocalo_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import getpass
import socket
from dataclasses import dataclass
from typing import Optional

import zocalo.configuration
from workflows.transport import lookup
Expand Down Expand Up @@ -32,7 +31,7 @@ class ZocaloStartInfo:
"""

ispyb_dcid: int
filename: Optional[str]
filename: str | None
start_frame_index: int
number_of_frames: int
message_index: int
Expand Down
Loading

0 comments on commit be80792

Please sign in to comment.