From 5b83260f0d7726eb553bc7e6ef4283f2b2bf47a6 Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Mon, 18 Mar 2024 10:44:32 +0000 Subject: [PATCH] (#1218) Make pyright happy --- .../external_interaction/nexus/nexus_utils.py | 4 ++-- .../test_ispyb_dev_connection.py | 12 +++++++----- .../test_flyscan_xray_centre_plan.py | 8 +++++--- .../test_panda_flyscan_xray_centre_plan.py | 9 +++++---- .../ispyb/test_rotation_ispyb_store.py | 4 +++- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/hyperion/external_interaction/nexus/nexus_utils.py b/src/hyperion/external_interaction/nexus/nexus_utils.py index 2376c007a..99ceff5e5 100644 --- a/src/hyperion/external_interaction/nexus/nexus_utils.py +++ b/src/hyperion/external_interaction/nexus/nexus_utils.py @@ -134,6 +134,6 @@ def create_beam_and_attenuator_parameters( """ return ( # TODO 1173 Get this data from events rather than ispyb_params - Beam(convert_eV_to_angstrom(energy_kev * 1000), flux), - Attenuator(transmission_fraction), + Beam(convert_eV_to_angstrom(energy_kev * 1000), flux), # pyright: ignore + Attenuator(transmission_fraction), # pyright: ignore ) diff --git a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py index f083ce9d8..ce010900a 100644 --- a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py +++ b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py @@ -335,18 +335,20 @@ def test_ispyb_deposition_in_rotation_plan( test_rotation_params.hyperion_params.ispyb_params.beam_size_y = test_bs_y test_rotation_params.hyperion_params.detector_params.exposure_time = test_exp_time energy_ev = convert_angstrom_to_eV(test_wl) - fake_create_rotation_devices.dcm.energy_in_kev.user_readback.sim_put( + fake_create_rotation_devices.dcm.energy_in_kev.user_readback.sim_put( # pyright: ignore energy_ev / 1000 ) fake_create_rotation_devices.undulator.current_gap.sim_put(1.12) - fake_create_rotation_devices.synchrotron.machine_status.synchrotron_mode.sim_put( + fake_create_rotation_devices.synchrotron.machine_status.synchrotron_mode.sim_put( # pyright: ignore test_synchrotron_mode.value ) - fake_create_rotation_devices.synchrotron.top_up.start_countdown.sim_put(-1) - fake_create_rotation_devices.s4_slit_gaps.xgap.user_readback.sim_put( + fake_create_rotation_devices.synchrotron.top_up.start_countdown.sim_put( # pyright: ignore + -1 + ) + fake_create_rotation_devices.s4_slit_gaps.xgap.user_readback.sim_put( # pyright: ignore test_slit_gap_horiz ) - fake_create_rotation_devices.s4_slit_gaps.ygap.user_readback.sim_put( + fake_create_rotation_devices.s4_slit_gaps.ygap.user_readback.sim_put( # pyright: ignore test_slit_gap_vert ) test_rotation_params.hyperion_params.detector_params.expected_energy_ev = energy_ev diff --git a/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py index 3753bda55..ee4a6b7f2 100644 --- a/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py @@ -231,15 +231,16 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( fake_fgs_composite.aperture_scatterguard, ) ) + # fmt: off assert_event( - test_ispyb_callback.activity_gated_start.mock_calls[0], + test_ispyb_callback.activity_gated_start.mock_calls[0], # pyright: ignore { "plan_name": "standalone_read_hardware_for_ispyb", "subplan_name": "run_gridscan_move_and_tidy", }, ) assert_event( - test_ispyb_callback.activity_gated_event.mock_calls[0], + test_ispyb_callback.activity_gated_event.mock_calls[0], # pyright: ignore { "undulator_current_gap": undulator_test_value, "synchrotron-synchrotron_mode": synchrotron_test_value.value, @@ -249,13 +250,14 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( }, ) assert_event( - test_ispyb_callback.activity_gated_event.mock_calls[1], + test_ispyb_callback.activity_gated_event.mock_calls[1], # pyright: ignore { "attenuator_actual_transmission": transmission_test_value, "flux_flux_reading": flux_test_value, "dcm_energy_in_kev": current_energy_kev_test_value, }, ) + # fmt: on @patch( "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", diff --git a/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py index d1c66b737..0a337c19b 100644 --- a/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py @@ -181,16 +181,16 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( fake_fgs_composite.aperture_scatterguard, ) ) - + # fmt: off assert_event( - test_ispyb_callback.activity_gated_start.mock_calls[0], + test_ispyb_callback.activity_gated_start.mock_calls[0], # pyright: ignore { "plan_name": "standalone_read_hardware_for_ispyb", "subplan_name": "run_gridscan_move_and_tidy", }, ) assert_event( - test_ispyb_callback.activity_gated_event.mock_calls[0], + test_ispyb_callback.activity_gated_event.mock_calls[0], # pyright: ignore { "undulator_current_gap": undulator_test_value, "synchrotron-synchrotron_mode": synchrotron_test_value.value, @@ -200,12 +200,13 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( }, ) assert_event( - test_ispyb_callback.activity_gated_event.mock_calls[1], + test_ispyb_callback.activity_gated_event.mock_calls[1], # pyright: ignore { "attenuator_actual_transmission": transmission_test_value, "flux_flux_reading": flux_test_value, }, ) + # fmt: on @patch( "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", diff --git a/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py b/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py index f11f34941..28d887322 100644 --- a/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py +++ b/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py @@ -180,7 +180,9 @@ def scan_data_info_for_update(scan_data_info_for_begin): @pytest.fixture def dummy_rotation_ispyb_with_experiment_type(): - store_in_ispyb = StoreInIspyb(CONST.SIM.ISPYB_CONFIG, "Characterization") + store_in_ispyb = StoreInIspyb( + CONST.SIM.ISPYB_CONFIG, ExperimentType.CHARACTERIZATION + ) return store_in_ispyb