From db28d5f624c940cbd27d75fb83c8ad992d1a265e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 01:52:43 +0000 Subject: [PATCH 1/2] Bump ruff from 0.8.6 to 0.9.0 in /requirements Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.6 to 0.9.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.6...0.9.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/test.txt b/requirements/test.txt index 5f27affd..6ad3a8a8 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,4 +2,4 @@ packaging==24.2 pytest==8.3.4 pytest-xdist==3.6.1 pytest-cov==6.0.0 -ruff==0.8.6 +ruff==0.9.0 From 6d426c451b295f693b956d2b8d20b1418c2f4f13 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 11 Jan 2025 14:23:00 +0100 Subject: [PATCH 2/2] Update ruff --- pyproject.toml | 2 +- requirements/test.txt | 2 +- .../decoders/unetplusplus/decoder.py | 6 +++--- segmentation_models_pytorch/encoders/mix_transformer.py | 6 +++--- segmentation_models_pytorch/encoders/mobileone.py | 4 +--- segmentation_models_pytorch/losses/dice.py | 6 +++--- segmentation_models_pytorch/losses/jaccard.py | 6 +++--- tests/encoders/base.py | 4 ++-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0e9310b5..3e44d723 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ test = [ 'pytest', 'pytest-cov', 'pytest-xdist', - 'ruff', + 'ruff>=0.9', ] [project.urls] diff --git a/requirements/test.txt b/requirements/test.txt index 6ad3a8a8..755b851d 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,4 +2,4 @@ packaging==24.2 pytest==8.3.4 pytest-xdist==3.6.1 pytest-cov==6.0.0 -ruff==0.9.0 +ruff==0.9.1 diff --git a/segmentation_models_pytorch/decoders/unetplusplus/decoder.py b/segmentation_models_pytorch/decoders/unetplusplus/decoder.py index 54ec7576..feafb5d4 100644 --- a/segmentation_models_pytorch/decoders/unetplusplus/decoder.py +++ b/segmentation_models_pytorch/decoders/unetplusplus/decoder.py @@ -119,7 +119,7 @@ def __init__( blocks[f"x_{depth_idx}_{layer_idx}"] = DecoderBlock( in_ch, skip_ch, out_ch, **kwargs ) - blocks[f"x_{0}_{len(self.in_channels)-1}"] = DecoderBlock( + blocks[f"x_{0}_{len(self.in_channels) - 1}"] = DecoderBlock( self.in_channels[-1], 0, self.out_channels[-1], **kwargs ) self.blocks = nn.ModuleDict(blocks) @@ -148,8 +148,8 @@ def forward(self, *features): ) dense_x[f"x_{depth_idx}_{dense_l_i}"] = self.blocks[ f"x_{depth_idx}_{dense_l_i}" - ](dense_x[f"x_{depth_idx}_{dense_l_i-1}"], cat_features) + ](dense_x[f"x_{depth_idx}_{dense_l_i - 1}"], cat_features) dense_x[f"x_{0}_{self.depth}"] = self.blocks[f"x_{0}_{self.depth}"]( - dense_x[f"x_{0}_{self.depth-1}"] + dense_x[f"x_{0}_{self.depth - 1}"] ) return dense_x[f"x_{0}_{self.depth}"] diff --git a/segmentation_models_pytorch/encoders/mix_transformer.py b/segmentation_models_pytorch/encoders/mix_transformer.py index 0cc3fb21..cf4c3f33 100644 --- a/segmentation_models_pytorch/encoders/mix_transformer.py +++ b/segmentation_models_pytorch/encoders/mix_transformer.py @@ -82,9 +82,9 @@ def __init__( sr_ratio=1, ): super().__init__() - assert ( - dim % num_heads == 0 - ), f"dim {dim} should be divided by num_heads {num_heads}." + assert dim % num_heads == 0, ( + f"dim {dim} should be divided by num_heads {num_heads}." + ) self.dim = dim self.num_heads = num_heads diff --git a/segmentation_models_pytorch/encoders/mobileone.py b/segmentation_models_pytorch/encoders/mobileone.py index 76f50053..1c031d28 100644 --- a/segmentation_models_pytorch/encoders/mobileone.py +++ b/segmentation_models_pytorch/encoders/mobileone.py @@ -381,9 +381,7 @@ def _make_stage( for ix, stride in enumerate(strides): use_se = False if num_se_blocks > num_blocks: - raise ValueError( - "Number of SE blocks cannot " "exceed number of layers." - ) + raise ValueError("Number of SE blocks cannot exceed number of layers.") if ix >= (num_blocks - num_se_blocks): use_se = True diff --git a/segmentation_models_pytorch/losses/dice.py b/segmentation_models_pytorch/losses/dice.py index d9283161..b8baae98 100644 --- a/segmentation_models_pytorch/losses/dice.py +++ b/segmentation_models_pytorch/losses/dice.py @@ -44,9 +44,9 @@ def __init__( super(DiceLoss, self).__init__() self.mode = mode if classes is not None: - assert ( - mode != BINARY_MODE - ), "Masking classes is not supported with mode=binary" + assert mode != BINARY_MODE, ( + "Masking classes is not supported with mode=binary" + ) classes = to_tensor(classes, dtype=torch.long) self.classes = classes diff --git a/segmentation_models_pytorch/losses/jaccard.py b/segmentation_models_pytorch/losses/jaccard.py index d6aba280..b250cacf 100644 --- a/segmentation_models_pytorch/losses/jaccard.py +++ b/segmentation_models_pytorch/losses/jaccard.py @@ -43,9 +43,9 @@ def __init__( self.mode = mode if classes is not None: - assert ( - mode != BINARY_MODE - ), "Masking classes is not supported with mode=binary" + assert mode != BINARY_MODE, ( + "Masking classes is not supported with mode=binary" + ) classes = to_tensor(classes, dtype=torch.long) self.classes = classes diff --git a/tests/encoders/base.py b/tests/encoders/base.py index 39cd4164..0f762cf4 100644 --- a/tests/encoders/base.py +++ b/tests/encoders/base.py @@ -127,12 +127,12 @@ def test_depth(self): self.assertEqual( height_strides, self.output_strides[: depth + 1], - f"Encoder `{encoder_name}` should have output strides {self.output_strides[:depth + 1]}, but has {height_strides}", + f"Encoder `{encoder_name}` should have output strides {self.output_strides[: depth + 1]}, but has {height_strides}", ) self.assertEqual( width_strides, self.output_strides[: depth + 1], - f"Encoder `{encoder_name}` should have output strides {self.output_strides[:depth + 1]}, but has {width_strides}", + f"Encoder `{encoder_name}` should have output strides {self.output_strides[: depth + 1]}, but has {width_strides}", ) # check encoder output stride property