diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c86799e34..ded3f1cb4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: trailing-whitespace exclude: "tests/cis_tests/.*" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.3 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/src/snapred/backend/dao/state/RunNumber.py b/src/snapred/backend/dao/state/RunNumber.py index bc6bb5de0..1152f222b 100644 --- a/src/snapred/backend/dao/state/RunNumber.py +++ b/src/snapred/backend/dao/state/RunNumber.py @@ -23,8 +23,7 @@ def validateRunNumber(cls, value): f"Run number {value} does not meet the minimum required value or does not have cached data available." ) raise ValueError( - f"Run number {value} is below the minimum value or data does not exist." - "Please enter a valid run number." + f"Run number {value} is below the minimum value or data does not exist.Please enter a valid run number." ) return value diff --git a/src/snapred/backend/error/StateValidationException.py b/src/snapred/backend/error/StateValidationException.py index b4a3ea6ad..4933b934b 100644 --- a/src/snapred/backend/error/StateValidationException.py +++ b/src/snapred/backend/error/StateValidationException.py @@ -29,7 +29,7 @@ def __init__(self, exception: Exception): doesFileExist, hasWritePermission = self._checkFileAndPermissions(filePath) if filePath and doesFileExist and hasWritePermission: - self.message = f"The following error occurred:{exceptionStr}\n\n" "Please contact your IS or CIS." + self.message = f"The following error occurred:{exceptionStr}\n\nPlease contact your IS or CIS." elif filePath and doesFileExist: self.message = f"You do not have write permissions: {filePath}" elif filePath: diff --git a/src/snapred/backend/service/CalibrationService.py b/src/snapred/backend/service/CalibrationService.py index 4fb933cdb..a557564b0 100644 --- a/src/snapred/backend/service/CalibrationService.py +++ b/src/snapred/backend/service/CalibrationService.py @@ -204,7 +204,7 @@ def pixelCalibration(self, request: SimpleDiffCalRequest) -> PixelDiffCalServing res.result = False raise Exception( ( - f"WARNING: More than {threshold*100}% of pixels failed calibration. Please check your input " + f"WARNING: More than {threshold * 100}% of pixels failed calibration. Please check your input " "data. If input data has poor statistics, you may get better results by disabling Cross " "Correlation. You can also improve statistics by activating Lite mode if this is not " "already activated." diff --git a/src/snapred/backend/service/ReductionService.py b/src/snapred/backend/service/ReductionService.py index 23189f042..528ff59b8 100644 --- a/src/snapred/backend/service/ReductionService.py +++ b/src/snapred/backend/service/ReductionService.py @@ -117,8 +117,7 @@ def validateReduction(self, request: ReductionRequest): # Case: No calibration but normalization exists continueFlags |= ContinueWarning.Type.MISSING_DIFFRACTION_CALIBRATION message = ( - "Warning: diffraction calibration is missing." - "If you continue, default instrument geometry will be used." + "Warning: diffraction calibration is missing.If you continue, default instrument geometry will be used." ) elif calibrationExists and not normalizationExists: # Case: Calibration exists but normalization is missing diff --git a/tests/unit/backend/dao/test_CalibrantSample.py b/tests/unit/backend/dao/test_CalibrantSample.py index aa719f47d..deb4e99a1 100644 --- a/tests/unit/backend/dao/test_CalibrantSample.py +++ b/tests/unit/backend/dao/test_CalibrantSample.py @@ -39,10 +39,10 @@ def test_setCalibrantSample(self): ref = f""" <{self.geo.shape.lower()} id="sample-shape"> - + - - + + """ diff --git a/tests/unit/backend/dao/test_Geometry.py b/tests/unit/backend/dao/test_Geometry.py index ecf62e4f9..d0e1fa4e1 100644 --- a/tests/unit/backend/dao/test_Geometry.py +++ b/tests/unit/backend/dao/test_Geometry.py @@ -90,10 +90,10 @@ def test_settableInMantidJSON(self): ref = f""" <{self.cylinder.shape.lower()} id="sample-shape"> - + - - + + """ @@ -111,7 +111,7 @@ def test_settableInMantidJSON(self): <{self.sphere.shape.lower()} id="sphere">
- + """ @@ -138,10 +138,10 @@ def test_settableInMantidDict(self): ref = f""" <{self.cylinder.shape.lower()} id="sample-shape"> - + - - + + """ @@ -159,7 +159,7 @@ def test_settableInMantidDict(self): <{self.sphere.shape.lower()} id="sphere">
- + """ diff --git a/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py b/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py index 850e71da6..4333f391c 100644 --- a/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py +++ b/tests/unit/backend/recipe/algorithm/test_FocusSpectraAlgorithm.py @@ -61,7 +61,7 @@ def makeFakeNeutronData(self, rawWsName: str, focusWSname: str) -> None: OutputWorkspace=rawWsName, # WorkspaceType="Histogram", Function="User Defined", - UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint/10}", + UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint / 10}", Xmin=overallDMin, Xmax=overallDMax, BinWidth=abs(dBin), @@ -202,7 +202,7 @@ def test_failedValidation_inputGroupingIdsMismatch(self): OutputWorkspace=self.fakeRawData, # WorkspaceType="Histogram", Function="User Defined", - UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint/10}", + UserDefinedFunction=f"name=Gaussian,Height=10,PeakCentre={midpoint},Sigma={midpoint / 10}", Xmin=overallDMin, Xmax=overallDMax, BinWidth=abs(dBin), diff --git a/tests/unit/backend/recipe/algorithm/test_RemoveSmoothedBackground.py b/tests/unit/backend/recipe/algorithm/test_RemoveSmoothedBackground.py index 6c25940b3..d61edac58 100644 --- a/tests/unit/backend/recipe/algorithm/test_RemoveSmoothedBackground.py +++ b/tests/unit/backend/recipe/algorithm/test_RemoveSmoothedBackground.py @@ -69,9 +69,9 @@ def test_chop_ingredients(self): assert groupID in algo.groupIDs, f"Group ID {groupID} not found in maskRegions" expected_group_ids = [peakList.groupID for peakList in peaks] - assert ( - algo.groupIDs == expected_group_ids - ), f"Group IDs in workspace and peak list do not match: {algo.groupIDs} vs {expected_group_ids}" + assert algo.groupIDs == expected_group_ids, ( + f"Group IDs in workspace and peak list do not match: {algo.groupIDs} vs {expected_group_ids}" + ) def test_incorrect_group_ids(self): peaks = [ diff --git a/tests/unit/backend/recipe/test_ReductionRecipe.py b/tests/unit/backend/recipe/test_ReductionRecipe.py index a6093d3e6..261943cfa 100644 --- a/tests/unit/backend/recipe/test_ReductionRecipe.py +++ b/tests/unit/backend/recipe/test_ReductionRecipe.py @@ -747,14 +747,14 @@ def test_execute_with_fully_masked_group(self, mockMtd): recipe.logger().warning.assert_any_call(expected_warning_message_group2) # Ensure the warning was called twice (once per group) - assert ( - recipe.logger().warning.call_count == 2 - ), "Expected warning to be logged twice for the fully masked groups." + assert recipe.logger().warning.call_count == 2, ( + "Expected warning to be logged twice for the fully masked groups." + ) # Ensure no algorithms were applied for the fully masked groups - assert ( - recipe._applyRecipe.call_count == 2 - ), "Expected _applyRecipe to not be called for the fully masked groups." + assert recipe._applyRecipe.call_count == 2, ( + "Expected _applyRecipe to not be called for the fully masked groups." + ) # Check the output result contains the mask workspace assert result["outputs"][0] == "mask", "Expected the mask workspace to be included in the outputs." diff --git a/tests/unit/meta/test_Config.py b/tests/unit/meta/test_Config.py index 8710758a2..bf6ea4571 100644 --- a/tests/unit/meta/test_Config.py +++ b/tests/unit/meta/test_Config.py @@ -212,8 +212,8 @@ def test_key_substitution(): def test_multi_level_substitution(): - assert Config["test.data.home.write"] == f'~/{Config["test.config.home"]}/data/{Config["test.config.name"]}' - assert Config["test.data.home.read"] == f'{Config["test.config.home"]}/data/{Config["test.config.name"]}' + assert Config["test.data.home.write"] == f"~/{Config['test.config.home']}/data/{Config['test.config.name']}" + assert Config["test.data.home.read"] == f"{Config['test.config.home']}/data/{Config['test.config.name']}" def test_fromMantidLoggingLevel():