From b9ca8b30941b9378046998967fb745b71faa6144 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Fri, 19 Sep 2025 10:16:47 +0000 Subject: [PATCH] Apply suggestions from code review of branch Increased-linting Co-authored-by: Beth Probert --- pyproject.toml | 2 +- src/openflexure_microscope_server/logging.py | 1 + tests/test_camera.py | 2 +- tests/test_dummy_server.py | 2 +- tests/test_version_strings.py | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aae45c65..dffc3831 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,7 +136,7 @@ ignore = [ "PLR2004", # Ignore magic values in comparison for now. It doesn't seem we can set # allowed magic values and a number of our magic values are not really # magic (such as 255 when doing uint8 maths) - "PT011", # Ifnore pytest.raises being used on too gereneral expectations without a + "PT011", # Ignore pytest.raises being used on too general expectations without a # match. We may need to revisit this. "SIM105", # Not enforcing use of `contextlib.suppress(NotConnectedToServerError)` # instead of `try`-`except`-`pass` diff --git a/src/openflexure_microscope_server/logging.py b/src/openflexure_microscope_server/logging.py index d50fb72f..ff4f8de7 100644 --- a/src/openflexure_microscope_server/logging.py +++ b/src/openflexure_microscope_server/logging.py @@ -34,6 +34,7 @@ def configure_logging(log_folder: str) -> None: root_logger = logging.getLogger() root_logger.setLevel(logging.INFO) # Explicitly make OFM_LOG_FILE a global so it can be updated based on log settings + # This requires silencing PLW0603 which disallows globals. global OFM_LOG_FILE # noqa: PLW0603 OFM_LOG_FILE = os.path.join(log_folder, "openflexure_microscope.log") diff --git a/tests/test_camera.py b/tests/test_camera.py index 2965b4d2..39a35d89 100644 --- a/tests/test_camera.py +++ b/tests/test_camera.py @@ -55,7 +55,7 @@ def test_handle_broken_frame(): # Check that this does cause broken frames. # The noqa is because we don't know exactly when the error is thrown so we - # can't have a single simple statements in the pytest raises. + # can't have a single simple statement in the pytest raises. with pytest.raises( # noqa PT012 OSError, match="broken data stream when reading image file" ): diff --git a/tests/test_dummy_server.py b/tests/test_dummy_server.py index cf745764..3f911992 100644 --- a/tests/test_dummy_server.py +++ b/tests/test_dummy_server.py @@ -42,7 +42,7 @@ def thing_server(): server.add_thing(CameraStageMapper(), "/camera_stage_mapping/") assert os.path.exists(os.path.join(temp_folder.name, "camera/")) # Note: yield is important. If return is used the temp folder gets deleted - # before the test runs + # before the test runs. Silence PT022 as ruff doesn't think yield is needed. yield server # noqa: PT022 diff --git a/tests/test_version_strings.py b/tests/test_version_strings.py index e1719c33..b1a9fa50 100644 --- a/tests/test_version_strings.py +++ b/tests/test_version_strings.py @@ -82,7 +82,7 @@ def git_repo(temp_dir): _git("add -A") _git("commit -m 'message2'") - # Yielding here as temdir is yielding and we want to stay in the tempdir + # Yielding here as tempdir is yielding and we want to stay in the tempdir # context manager. Silencing ruff saying it should be return. yield temp_dir # noqa: PT022