Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#496)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.8.0](astral-sh/ruff-pre-commit@v0.5.5...v0.8.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Dec 2, 2024
1 parent 0720419 commit b628382
Show file tree
Hide file tree
Showing 101 changed files with 202 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=8192]
Expand All @@ -16,7 +16,7 @@ repos:
- id: trailing-whitespace
exclude: "tests/cis_tests/.*"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions src/snapred/backend/dao/indexing/CalculationParameters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime

from pydantic import field_validator

from snapred.backend.dao.indexing.Versioning import VersionedObject
from snapred.backend.dao.state.InstrumentState import InstrumentState

Expand Down
1 change: 1 addition & 0 deletions src/snapred/backend/dao/indexing/IndexEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Optional

from pydantic import Field, field_validator, model_validator

from snapred.backend.dao.indexing.Versioning import VersionedObject


Expand Down
1 change: 1 addition & 0 deletions src/snapred/backend/dao/indexing/Record.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

from pydantic import ConfigDict, field_validator

from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters
from snapred.backend.dao.indexing.Versioning import VersionedObject

Expand Down
1 change: 1 addition & 0 deletions src/snapred/backend/dao/indexing/Versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from numpy import integer
from pydantic import BaseModel, computed_field, field_serializer

from snapred.meta.Config import Config

VERSION_START = Config["version.start"]
Expand Down
5 changes: 3 additions & 2 deletions src/snapred/ui/view/reduction/ArtificialNormalizationView.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
QMessageBox,
QPushButton,
)
from workbench.plotting.figuremanager import MantidFigureCanvas
from workbench.plotting.toolbar import WorkbenchNavigationToolbar

from snapred.meta.Config import Config
from snapred.meta.decorators.Resettable import Resettable
from snapred.ui.view.BackendRequestView import BackendRequestView
from workbench.plotting.figuremanager import MantidFigureCanvas
from workbench.plotting.toolbar import WorkbenchNavigationToolbar


@Resettable
Expand Down
1 change: 1 addition & 0 deletions src/snapred/ui/view/reduction/ReductionRequestView.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
QPushButton,
QVBoxLayout,
)

from snapred.backend.dao.state.RunNumber import RunNumber
from snapred.backend.log.logger import snapredLogger
from snapred.meta.decorators.Resettable import Resettable
Expand Down
1 change: 1 addition & 0 deletions src/snapred/ui/view/reduction/ReductionSaveView.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from qtpy.QtCore import Signal, Slot
from qtpy.QtWidgets import QLabel

from snapred.backend.error.ContinueWarning import ContinueWarning
from snapred.meta.decorators.Resettable import Resettable
from snapred.ui.view.BackendRequestView import BackendRequestView
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_controller.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pytest

from snapred.backend.dao.SNAPRequest import SNAPRequest


@pytest.mark.integration()
@pytest.mark.integration
def test_executeRequest_noop():
# import must be here or it will put things in a funny state and break other tests
from snapred.backend.api.InterfaceController import InterfaceController
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_diffcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from cis_tests.diffcal_integration_test_script import script as test_script

from snapred.meta.Config import Config, Resource


Expand All @@ -27,7 +28,7 @@ def _cleanup_directories():
@pytest.mark.golden_data(
path=Resource.getPath("outputs/integration/diffcal/golden_data"), short_name="diffcal", date="2024-04-24"
)
@pytest.mark.integration()
@pytest.mark.integration
def test_diffcal(goldenData):
# to launch, use either of:
# * `env=integration_test pytest -m integration`, or
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/test_versions_in_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
LoadEmptyInstrument,
mtd,
)
from util.dao import DAOFactory
from util.diffraction_calibration_synthetic_data import SyntheticData

from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord
from snapred.backend.dao.indexing.IndexEntry import IndexEntry
from snapred.backend.dao.indexing.Versioning import VERSION_DEFAULT, VERSION_START
Expand All @@ -48,8 +51,6 @@
from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng
from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceType as wngt
from snapred.meta.redantic import parse_file_as, write_model_pretty
from util.dao import DAOFactory
from util.diffraction_calibration_synthetic_data import SyntheticData

dataSynthesizer = SyntheticData()

Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_workflow_panels_happy_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
QMessageBox,
QTabWidget,
)
from util.Config_helpers import Config_override

# I would prefer not to access `LocalDataService` within an integration test,
# however, for the moment, the reduction-data output relocation fixture is defined in the current file.
Expand All @@ -30,7 +31,6 @@
from snapred.ui.view.NormalizationTweakPeakView import NormalizationTweakPeakView
from snapred.ui.view.reduction.ReductionRequestView import ReductionRequestView
from snapred.ui.view.reduction.ReductionSaveView import ReductionSaveView
from util.Config_helpers import Config_override

# TODO: WorkflowNodeComplete signal, at end of each node!

Expand All @@ -39,7 +39,7 @@ class InterruptWithBlock(BaseException):
pass


@pytest.fixture()
@pytest.fixture
def calibration_home_from_mirror():
# Test fixture to create a copy of the calibration home directory from an existing mirror:
# * creates a temporary calibration home directory under the optional `prefix` path;
Expand Down Expand Up @@ -86,7 +86,7 @@ def _calibration_home_from_mirror(prefix: Optional[Path] = None):
LocalDataService()._indexer.cache_clear()


@pytest.fixture()
@pytest.fixture
def reduction_home_from_mirror():
# Test fixture to write reduction data to a temporary directory under `Config["instrument.reduction.home"]`.
# * creates a temporary reduction state root directory under the optional `prefix` path;
Expand Down Expand Up @@ -135,8 +135,8 @@ def _reduction_home_from_mirror(runNumber: str, prefix: Optional[Path] = None):
_stack.close()


@pytest.mark.datarepo()
@pytest.mark.integration()
@pytest.mark.datarepo
@pytest.mark.integration
class TestGUIPanels:
@pytest.fixture(scope="function", autouse=True) # noqa: PT003
def _setup_gui(self, qapp):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_AllowedPeaks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pydantic import ValidationError

from snapred.backend.dao.request.CalibrationAssessmentRequest import CalibrationAssessmentRequest
from snapred.meta.mantid.AllowedPeakTypes import allowed_peak_type_list
from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName as wngn
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_Atom.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pydantic import ValidationError

from snapred.backend.dao.state.CalibrantSample.Atom import Atom


Expand Down
3 changes: 2 additions & 1 deletion tests/unit/backend/dao/test_CalibrantSample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import unittest

from mantid.simpleapi import CreateWorkspace, DeleteWorkspace, SetSample
from snapred.backend.dao.state.CalibrantSample.CalibrantSample import CalibrantSample
from util.dao import DAOFactory

from snapred.backend.dao.state.CalibrantSample.CalibrantSample import CalibrantSample


class TestCalibrantSample(unittest.TestCase):
def setUp(self):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_Crystallography.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from mantid.geometry import CrystalStructure
from pydantic import ValidationError

from snapred.backend.dao.state.CalibrantSample.Atom import Atom
from snapred.backend.dao.state.CalibrantSample.Crystallography import Crystallography
from snapred.meta.Config import Resource
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_ForbidExtras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from pydantic import ValidationError

from snapred.backend.dao.ingredients.DiffractionCalibrationIngredients import DiffractionCalibrationIngredients
from snapred.backend.dao.request.DiffractionCalibrationRequest import DiffractionCalibrationRequest

Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from mantid.simpleapi import CreateWorkspace, SetSample

from snapred.backend.dao.state.CalibrantSample.Geometry import Geometry


Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_GroceryListBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
LoadEmptyInstrument,
)
from pydantic import ValidationError

from snapred.meta.builder.GroceryListBuilder import GroceryListBuilder
from snapred.meta.Config import Resource

Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_GroceryListItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
DeleteWorkspace,
LoadEmptyInstrument,
)

from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem
from snapred.meta.builder.GroceryListBuilder import GroceryListBuilder
from snapred.meta.Config import Resource
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/backend/dao/test_GroupingMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

# Important: this is a *pure* pytest module: no `unittest` imports should be used.
import pytest
from util.groupingMapUtil import GroupingMapTestFactory

from snapred.backend.dao.state import GroupingMap as GroupingMapModule
from snapred.meta.Config import Resource
from util.groupingMapUtil import GroupingMapTestFactory

GroupingMap = importlib.import_module(GroupingMapModule.__module__)

Expand All @@ -21,7 +22,7 @@ def _capture_logging(monkeypatch):
monkeypatch.setattr(GroupingMap, "logger", defaultLogger)


@pytest.fixture()
@pytest.fixture
def groupingMapFactory():
return GroupingMapTestFactory()

Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_IndexEntry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from snapred.backend.dao.indexing.IndexEntry import IndexEntry

testData = {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_Material.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from mantid.simpleapi import CreateWorkspace, DeleteWorkspace, SetSample

from snapred.backend.dao.state.CalibrantSample.Material import Material


Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_PixelGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest

import pytest

from snapred.backend.dao.Limit import BinnedValue, Limit
from snapred.backend.dao.state.FocusGroup import FocusGroup
from snapred.backend.dao.state.PixelGroup import PixelGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pydantic import ValidationError

from snapred.backend.dao.request import RenameWorkspacesFromTemplateRequest


Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_SNAPResponse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pydantic import ValidationError

from snapred.backend.dao.SNAPResponse import ResponseCode, SNAPResponse


Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_VersionedObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest
from numpy import int64

from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters
from snapred.backend.dao.indexing.IndexEntry import IndexEntry
from snapred.backend.dao.indexing.Record import Record
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/dao/test_WorkspaceMetadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pydantic import ValidationError

from snapred.backend.dao.WorkspaceMetadata import (
UNSET,
DiffcalStateMetadata,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/backend/data/test_DataFactoryService.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from random import randint

from mantid.simpleapi import CreateSingleValuedWorkspace, DeleteWorkspace, mtd

from snapred.backend.dao.calibration import Calibration
from snapred.backend.dao.InstrumentConfig import InstrumentConfig
from snapred.backend.dao.ReductionState import ReductionState
Expand Down
13 changes: 7 additions & 6 deletions tests/unit/backend/data/test_GroceryService.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from unittest import mock

import pytest
import snapred.backend.recipe.algorithm # noqa: F401
from mantid.dataobjects import MaskWorkspace
from mantid.kernel import V3D, Quat
from mantid.simpleapi import (
Expand All @@ -26,6 +25,13 @@
mtd,
)
from mantid.testing import assert_almost_equal as assert_wksp_almost_equal
from util.helpers import createCompatibleDiffCalTable, createCompatibleMask
from util.instrument_helpers import mapFromSampleLogs
from util.kernel_helpers import tupleFromQuat, tupleFromV3D
from util.state_helpers import reduction_root_redirect, state_root_redirect
from util.WhateversInTheFridge import WhateversInTheFridge

import snapred.backend.recipe.algorithm # noqa: F401
from snapred.backend.dao.ingredients.GroceryListItem import GroceryListItem
from snapred.backend.dao.state import DetectorState
from snapred.backend.dao.WorkspaceMetadata import UNSET, DiffcalStateMetadata, WorkspaceMetadata
Expand All @@ -35,11 +41,6 @@
from snapred.meta.mantid.WorkspaceNameGenerator import ValueFormatter as wnvf
from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng
from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceType
from util.helpers import createCompatibleDiffCalTable, createCompatibleMask
from util.instrument_helpers import mapFromSampleLogs
from util.kernel_helpers import tupleFromQuat, tupleFromV3D
from util.state_helpers import reduction_root_redirect, state_root_redirect
from util.WhateversInTheFridge import WhateversInTheFridge

ThisService = "snapred.backend.data.GroceryService."

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/backend/data/test_Indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import pytest
from pydantic import ValidationError
from util.dao import DAOFactory

from snapred.backend.dao.calibration.Calibration import Calibration
from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord
from snapred.backend.dao.indexing.CalculationParameters import CalculationParameters
Expand All @@ -23,7 +25,6 @@
from snapred.meta.Config import Resource
from snapred.meta.mantid.WorkspaceNameGenerator import ValueFormatter as wnvf
from snapred.meta.redantic import parse_file_as, write_model_list_pretty, write_model_pretty
from util.dao import DAOFactory

IndexerModule = importlib.import_module(Indexer.__module__)

Expand Down
Loading

0 comments on commit b628382

Please sign in to comment.