Apply suggestions from code review of branch Increased-linting

Co-authored-by: Beth Probert <beth_probert@outlook.com>
This commit is contained in:
Julian Stirling 2025-09-19 10:16:47 +00:00
parent b4e28e232e
commit b9ca8b3094
5 changed files with 5 additions and 4 deletions

View file

@ -136,7 +136,7 @@ ignore = [
"PLR2004", # Ignore magic values in comparison for now. It doesn't seem we can set "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 # allowed magic values and a number of our magic values are not really
# magic (such as 255 when doing uint8 maths) # 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. # match. We may need to revisit this.
"SIM105", # Not enforcing use of `contextlib.suppress(NotConnectedToServerError)` "SIM105", # Not enforcing use of `contextlib.suppress(NotConnectedToServerError)`
# instead of `try`-`except`-`pass` # instead of `try`-`except`-`pass`

View file

@ -34,6 +34,7 @@ def configure_logging(log_folder: str) -> None:
root_logger = logging.getLogger() root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO) root_logger.setLevel(logging.INFO)
# Explicitly make OFM_LOG_FILE a global so it can be updated based on log settings # 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 global OFM_LOG_FILE # noqa: PLW0603
OFM_LOG_FILE = os.path.join(log_folder, "openflexure_microscope.log") OFM_LOG_FILE = os.path.join(log_folder, "openflexure_microscope.log")

View file

@ -55,7 +55,7 @@ def test_handle_broken_frame():
# Check that this does cause broken frames. # Check that this does cause broken frames.
# The noqa is because we don't know exactly when the error is thrown so we # 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 with pytest.raises( # noqa PT012
OSError, match="broken data stream when reading image file" OSError, match="broken data stream when reading image file"
): ):

View file

@ -42,7 +42,7 @@ def thing_server():
server.add_thing(CameraStageMapper(), "/camera_stage_mapping/") server.add_thing(CameraStageMapper(), "/camera_stage_mapping/")
assert os.path.exists(os.path.join(temp_folder.name, "camera/")) assert os.path.exists(os.path.join(temp_folder.name, "camera/"))
# Note: yield is important. If return is used the temp folder gets deleted # 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 yield server # noqa: PT022

View file

@ -82,7 +82,7 @@ def git_repo(temp_dir):
_git("add -A") _git("add -A")
_git("commit -m 'message2'") _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. # context manager. Silencing ruff saying it should be return.
yield temp_dir # noqa: PT022 yield temp_dir # noqa: PT022