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 #998

Merged
merged 4 commits into from
Jul 30, 2023
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
- id: setup-cfg-fmt
args: ["--include-version-classifiers", "--max-py-version", "3.11"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.277
rev: v0.0.280
hooks:
- id: ruff
- repo: https://github.com/asottile/pyupgrade
Expand Down
2 changes: 1 addition & 1 deletion package/PartSeg/common_backend/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def __init__(self, json_path: Union[Path, str], profile_name: str = "default"):
"""
super().__init__()
napari_path = os.path.dirname(json_path) if os.path.basename(json_path) in ["analysis", "mask"] else json_path
self.napari_settings: "NapariSettings" = napari_get_settings(napari_path)
self.napari_settings: NapariSettings = napari_get_settings(napari_path)
self._current_roi_dict = profile_name
self._roi_dict = ProfileDict()
self._last_algorithm_dict = ProfileDict()
Expand Down
6 changes: 4 additions & 2 deletions package/PartSeg/plugins/napari_widgets/colormap_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ def __init__(
self.update_preview()

def update_preview(self, _event=None):
if len(self.viewer.layers.selection) == 1 and isinstance(list(self.viewer.layers.selection)[0], Image):
if len(self.viewer.layers.selection) == 1 and isinstance(next(iter(self.viewer.layers.selection)), Image):
self.apply_colormap_btn.setEnabled(True)
self.apply_colormap_btn.setToolTip("Apply colormap to selected layer")
else:
self.apply_colormap_btn.setEnabled(False)
self.apply_colormap_btn.setToolTip("Select one image layer to apply colormap")

def apply_colormap(self):
if len(self.viewer.layers.selection) == 1 and isinstance(layer := list(self.viewer.layers.selection)[0], Image):
if len(self.viewer.layers.selection) == 1 and isinstance(
layer := next(iter(self.viewer.layers.selection)), Image
):
layer.colormap = self.colormap


Expand Down
4 changes: 2 additions & 2 deletions package/PartSeg/plugins/napari_widgets/lables_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, viewer: Viewer, name: str, label: List[Sequence[float]], remo
self.apply_label_btn.clicked.connect(self.apply_label)

def update_preview(self, _event=None):
if len(self.viewer.layers.selection) == 1 and isinstance(list(self.viewer.layers.selection)[0], Labels):
if len(self.viewer.layers.selection) == 1 and isinstance(next(iter(self.viewer.layers.selection)), Labels):
self.apply_label_btn.setEnabled(True)
self.apply_label_btn.setToolTip("Apply labels to selected layer")
else:
Expand All @@ -32,7 +32,7 @@ def update_preview(self, _event=None):

def apply_label(self):
if len(self.viewer.layers.selection) == 1 and isinstance(
layer := list(self.viewer.layers.selection)[0], Labels
layer := next(iter(self.viewer.layers.selection)), Labels
):
max_val = layer.data.max()
labels = {i + 1: [x / 255 for x in self.label[i % len(self.label)]] for i in range(max_val + 5)}
Expand Down
2 changes: 1 addition & 1 deletion package/PartSegCore/algorithm_describe_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def base_model_to_algorithm_property(obj: typing.Type[BaseModel]) -> typing.List
:return:
"""
res = []
value: "ModelField"
value: ModelField
if hasattr(obj, "header") and obj.header():
res.append(obj.header())
for name, value in obj.__fields__.items():
Expand Down
4 changes: 2 additions & 2 deletions package/PartSegCore/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def load_metadata_base(data: typing.Union[str, Path]):
except ValueError as e:
try:
decoded_data = json.loads(str(data), object_hook=partseg_object_hook)
except Exception:
raise e
except Exception: # pragma: no cover
raise e # noqa: B904

return decoded_data

Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_PartSeg/test_colormap_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def check_res(colormap):

cmap_dict = base_settings.get_from_profile("custom_colormap")
assert len(cmap_dict) == 1
assert check_res(list(cmap_dict.values())[0])
assert check_res(next(iter(cmap_dict.values())))

def test_custom_colors_save(self, qtbot, base_settings):
widget = PColormapCreator(base_settings)
Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_PartSegCore/test_analysis_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def test_fail_single_mask_project(self, tmp_path, calculation_plan_dummy):
res = calc_process.do_calculation(FileCalculation(file_path, calc))
assert len(res) == 4
assert sum(isinstance(x, ResponseData) for x in res) == 3
assert isinstance(list(dropwhile(lambda x: isinstance(x, ResponseData), res))[0][0], ValueError)
assert isinstance(next(iter(dropwhile(lambda x: isinstance(x, ResponseData), res)))[0], ValueError)

@pytest.mark.usefixtures("_prepare_spacing_data")
@pytest.mark.usefixtures("_register_dummy_spacing")
Expand Down