Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: [pre-commit.ci] pre-commit autoupdate #1184

Merged
merged 9 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test_prereleases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ jobs:
uses: aganders3/headless-gui@v2
timeout-minutes: 60
with:
run: python -m tox -v --pre
run: python -m tox run -v -- -v
env:
PLATFORM: ${{ matrix.platform }}
PYVISTA_OFF_SCREEN: True # required for opengl on windows
NAPARI: latest
BACKEND: PyQt5
PIP_CONSTRAINT: requirements/pre_test_problematic_version.txt
PIP_PRE: 1

# If something goes wrong, we can open an issue in the repo
- name: Report Failures
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.6.3
hooks:
- id: ruff
- repo: https://github.com/pre-commit/pygrep-hooks
Expand All @@ -39,7 +39,7 @@ repos:
- mdformat-toc

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.11.1' # Use the sha / tag you want to point at
rev: 'v1.11.2' # Use the sha / tag you want to point at
hooks:
- id: mypy
files: ^package/PartSegImage/.+\.py
Expand Down
2 changes: 1 addition & 1 deletion package/PartSegImage/tifffile_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def asarray(self, *args, **kwargs):
self.parent.report_func()
return res

def _dummy_report_func(self): # noqa: ARG001
def _dummy_report_func(self):
"""dummy function for report_func"""
Comment on lines +22 to 23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused self parameter.

The self parameter is unused in the _dummy_report_func method. Removing it will clean up the code.

Apply this diff to remove the unused parameter:

-def _dummy_report_func(self):
+def _dummy_report_func():
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def _dummy_report_func(self):
"""dummy function for report_func"""
def _dummy_report_func():
"""dummy function for report_func"""
Tools
Ruff

22-22: Unused function argument: self

(ARG001)


TiffFile.report_func = _dummy_report_func
Expand Down
40 changes: 20 additions & 20 deletions package/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def bundle_test_dir():
return Path(os.path.join(os.path.dirname(__file__), "test_data"))


@pytest.fixture()
@pytest.fixture
def image(tmp_path):
data = np.zeros([20, 20, 20, 2], dtype=np.uint16)
data[10:-1, 1:-1, 1:-1, 0] = 20
Expand All @@ -56,7 +56,7 @@ def image(tmp_path):
return Image(data, (10**-3, 10**-3, 10**-3), axes_order="ZYXC", file_path=str(tmp_path / "test.tiff"))


@pytest.fixture()
@pytest.fixture
def image2(image, tmp_path):
data = np.zeros([20, 20, 20, 1], dtype=np.uint8)
data[10:-1, 1:-1, 1:-1, 0] = 20
Expand All @@ -65,14 +65,14 @@ def image2(image, tmp_path):
return img


@pytest.fixture()
@pytest.fixture
def image2d(tmp_path):
data = np.zeros([20, 20], dtype=np.uint8)
data[10:-1, 1:-1] = 20
return Image(data, (10**-3, 10**-3), axes_order="YX", file_path=str(tmp_path / "test.tiff"))


@pytest.fixture()
@pytest.fixture
def stack_image():
data = np.zeros([20, 40, 40, 2], dtype=np.uint8)
for x, y in itertools.product([0, 20], repeat=2):
Expand All @@ -85,7 +85,7 @@ def stack_image():
return MaskProjectTuple("test_path", Image(data, (2, 1, 1), axes_order="ZYXC", file_path="test_path"))


@pytest.fixture()
@pytest.fixture
def algorithm_parameters():
algorithm_parameters = {
"algorithm_name": "Lower threshold",
Expand All @@ -100,7 +100,7 @@ def algorithm_parameters():
return deepcopy(algorithm_parameters)


@pytest.fixture()
@pytest.fixture
def roi_extraction_profile():
return ROIExtractionProfile(
name="test",
Expand All @@ -109,7 +109,7 @@ def roi_extraction_profile():
)


@pytest.fixture()
@pytest.fixture
def mask_segmentation_parameters():
return ROIExtractionProfile(
name="",
Expand All @@ -128,7 +128,7 @@ def mask_segmentation_parameters():
)


@pytest.fixture()
@pytest.fixture
def stack_segmentation1(stack_image: MaskProjectTuple, mask_segmentation_parameters):
data = np.zeros([20, 40, 40], dtype=np.uint8)
for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1):
Expand All @@ -140,7 +140,7 @@ def stack_segmentation1(stack_image: MaskProjectTuple, mask_segmentation_paramet
)


@pytest.fixture()
@pytest.fixture
def analysis_segmentation(stack_image: MaskProjectTuple):
data = np.zeros([20, 40, 40], dtype=np.uint8)
for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1):
Expand All @@ -149,13 +149,13 @@ def analysis_segmentation(stack_image: MaskProjectTuple):
return ProjectTuple(file_path=stack_image.file_path, image=stack_image.image, roi_info=data)


@pytest.fixture()
@pytest.fixture
def analysis_segmentation2(analysis_segmentation: ProjectTuple):
mask = (analysis_segmentation.roi_info.roi > 0).astype(np.uint8)
return dataclasses.replace(analysis_segmentation, mask=mask)


@pytest.fixture()
@pytest.fixture
def stack_segmentation2(stack_image: MaskProjectTuple, mask_segmentation_parameters):
data = np.zeros([20, 40, 40], dtype=np.uint8)
for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1):
Expand All @@ -168,12 +168,12 @@ def stack_segmentation2(stack_image: MaskProjectTuple, mask_segmentation_paramet
)


@pytest.fixture()
@pytest.fixture
def mask_property():
return MaskProperty.simple_mask()


@pytest.fixture()
@pytest.fixture
def mask_property_non_default():
return MaskProperty(
dilate=RadiusType.R2D,
Expand All @@ -186,7 +186,7 @@ def mask_property_non_default():
)


@pytest.fixture()
@pytest.fixture
def measurement_profiles():
statistics = [
MeasurementEntry(
Expand Down Expand Up @@ -221,14 +221,14 @@ def measurement_profiles():
)


@pytest.fixture()
@pytest.fixture
def border_rim_profile():
return ROIExtractionProfile(
name="border_profile", algorithm=BorderRim.get_name(), values=BorderRim.get_default_values()
)


@pytest.fixture()
@pytest.fixture
def lower_threshold_profile():
return ROIExtractionProfile(
name="lower_profile",
Expand All @@ -237,7 +237,7 @@ def lower_threshold_profile():
)


@pytest.fixture()
@pytest.fixture
def mask_threshold_profile():
return ROIExtractionProfile(
name="mask_profile",
Expand All @@ -246,7 +246,7 @@ def mask_threshold_profile():
)


@pytest.fixture()
@pytest.fixture
def sample_pipeline(border_rim_profile, lower_threshold_profile, mask_property):
return SegmentationPipeline(
name="sample_pipeline",
Expand All @@ -255,7 +255,7 @@ def sample_pipeline(border_rim_profile, lower_threshold_profile, mask_property):
)


@pytest.fixture()
@pytest.fixture
def sample_pipeline2(border_rim_profile, lower_threshold_profile, mask_property):
return SegmentationPipeline(
name="sample_pipeline2",
Expand All @@ -264,7 +264,7 @@ def sample_pipeline2(border_rim_profile, lower_threshold_profile, mask_property)
)


@pytest.fixture()
@pytest.fixture
def history_element(image, lower_threshold_profile):
roi = np.zeros(image.shape, dtype=np.uint8)
roi[0, 2:10] = 1
Expand Down
8 changes: 4 additions & 4 deletions package/tests/test_PartSeg/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from PartSeg.common_gui import napari_image_view


@pytest.fixture()
@pytest.fixture
def base_settings(image, tmp_path, measurement_profiles):
settings = BaseSettings(tmp_path)
settings.image = image
return settings


@pytest.fixture()
@pytest.fixture
def part_settings(image, tmp_path, measurement_profiles):
settings = PartSettings(tmp_path)
settings.image = image
Expand All @@ -27,7 +27,7 @@ def part_settings(image, tmp_path, measurement_profiles):
return settings


@pytest.fixture()
@pytest.fixture
def stack_settings(tmp_path, image):
settings = StackSettings(tmp_path)
settings.image = image
Expand All @@ -37,7 +37,7 @@ def stack_settings(tmp_path, image):
chose.deleteLater()


@pytest.fixture()
@pytest.fixture
def part_settings_with_project(image, analysis_segmentation2, tmp_path):
settings = PartSettings(tmp_path)
settings.image = image
Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_PartSeg/roi_analysis/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PartSegCore.analysis.calculation_plan import CalculationPlan, CalculationTree, MaskSuffix, RootType


@pytest.fixture()
@pytest.fixture
def calculation_prepare(tmp_path, part_settings, qtbot):
def _constructor(file_list, calculation_plan=None):
if calculation_plan is None:
Expand Down
4 changes: 2 additions & 2 deletions package/tests/test_PartSeg/roi_analysis/test_export_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)


@pytest.fixture()
@pytest.fixture
def _dummy_tiffs(tmp_path):
for i in range(1, 11):
(tmp_path / f"stack1_component{i}.tif").touch()
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_fail_export_empty_excel(tmp_path):
list(export_to_archive(tmp_path / "empty.xlsx", tmp_path, tmp_path / "arch.tar.gz"))


@pytest.fixture()
@pytest.fixture
def zenodo_kwargs():
return {
"zenodo_token": "sample_token",
Expand Down
8 changes: 4 additions & 4 deletions package/tests/test_PartSeg/roi_analysis/test_image_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from PartSegCore.roi_info import ROIInfo


@pytest.mark.windows_ci_skip()
@pytest.mark.windows_ci_skip
def test_synchronize(part_settings, image2, qtbot):
prop = ChannelProperty(part_settings, "test1")
view1 = ResultImageView(part_settings, prop, "test1")
Expand Down Expand Up @@ -36,7 +36,7 @@ def test_synchronize(part_settings, image2, qtbot):
view2.hide()


@pytest.mark.windows_ci_skip()
@pytest.mark.windows_ci_skip
def test_synchronize_change_image_dim(part_settings, image2, image2d, qtbot):
part_settings.image = image2d
prop = ChannelProperty(part_settings, "test1")
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_setting_properties(self, part_settings, image2, qtbot):
part_settings.set_in_profile("test.image_state.only_border", False)
assert not view.only_border.isChecked()

@pytest.mark.windows_ci_skip()
@pytest.mark.windows_ci_skip
def test_resize(self, part_settings, image2, qtbot):
prop = ChannelProperty(part_settings, "test")
view = ResultImageView(part_settings, prop, "test")
Expand All @@ -118,7 +118,7 @@ def test_resize(self, part_settings, image2, qtbot):
assert view.btn_layout2.count() == 2
view.hide()

@pytest.mark.windows_ci_skip()
@pytest.mark.windows_ci_skip
def test_with_roi_alternatives(self, part_settings, image2, qtbot):
prop = ChannelProperty(part_settings, "test")
view = ResultImageView(part_settings, prop, "test")
Expand Down
8 changes: 4 additions & 4 deletions package/tests/test_PartSeg/roi_analysis/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TestAnalysisMainWindow:
# @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="debug test fail")
@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_opening(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
Expand All @@ -22,15 +22,15 @@ def test_opening(self, qtbot, tmpdir):
main_window.advanced_window.close()
qtbot.wait(50)

@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_change_theme(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
assert main_window.raw_image.viewer.theme == "light"
main_window.settings.theme_name = "dark"
assert main_window.raw_image.viewer.theme == "dark"

@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_scale_bar(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
Expand All @@ -51,7 +51,7 @@ def test_get_project_info(self, image, tmp_path):
assert set(res.roi_info.bound_info) == {1}


@pytest.fixture()
@pytest.fixture
def analysis_options(qtbot, part_settings):
ch_property = ChannelProperty(part_settings, "test")
qtbot.addWidget(ch_property)
Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_PartSeg/roi_mask/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from PartSegCore.mask.io_functions import SaveROIOptions


@pytest.fixture()
@pytest.fixture
def batch_task(stack_image, mask_threshold_profile):
return BatchTask(stack_image, mask_threshold_profile, None)

Expand Down
8 changes: 4 additions & 4 deletions package/tests/test_PartSeg/roi_mask/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

class TestMaskMainWindow:
# @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="vispy problem")
@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_opening(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
qtbot.wait(50)

@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_change_theme(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
assert main_window.image_view.viewer.theme == "light"
main_window.settings.theme_name = "dark"
assert main_window.image_view.viewer.theme == "dark"

@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_scale_bar(self, qtbot, tmpdir):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
Expand All @@ -43,7 +43,7 @@ def test_get_project_info(self, image, tmp_path):
res = MainWindow.get_project_info(str(tmp_path / "test.tiff"), image, ROIInfo(roi))
assert res.roi_extraction_parameters == {1: None}

@pytest.mark.pyside_skip()
@pytest.mark.pyside_skip
def test_window_title(self, tmpdir, image, image2, qtbot):
main_window = MainWindow(tmpdir, initial_image=False)
qtbot.addWidget(main_window)
Expand Down
Loading
Loading