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

Bump ruff from 0.8.6 to 0.9.0 in /requirements #1028

Merged
merged 2 commits into from
Jan 11, 2025
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test = [
'pytest',
'pytest-cov',
'pytest-xdist',
'ruff',
'ruff>=0.9',
Copy link
Collaborator

Choose a reason for hiding this comment

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

ruff 0.8 will undo many of the formatting changes in ruff 0.9, let's set this as the new minimum version required.

]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
6 changes: 3 additions & 3 deletions segmentation_models_pytorch/decoders/unetplusplus/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}"]
6 changes: 3 additions & 3 deletions segmentation_models_pytorch/encoders/mix_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions segmentation_models_pytorch/encoders/mobileone.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@
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.")

Check warning on line 384 in segmentation_models_pytorch/encoders/mobileone.py

View check run for this annotation

Codecov / codecov/patch

segmentation_models_pytorch/encoders/mobileone.py#L384

Added line #L384 was not covered by tests
if ix >= (num_blocks - num_se_blocks):
use_se = True

Expand Down
6 changes: 3 additions & 3 deletions segmentation_models_pytorch/losses/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
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, (

Check warning on line 47 in segmentation_models_pytorch/losses/dice.py

View check run for this annotation

Codecov / codecov/patch

segmentation_models_pytorch/losses/dice.py#L47

Added line #L47 was not covered by tests
"Masking classes is not supported with mode=binary"
)
classes = to_tensor(classes, dtype=torch.long)

self.classes = classes
Expand Down
6 changes: 3 additions & 3 deletions segmentation_models_pytorch/losses/jaccard.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@

self.mode = mode
if classes is not None:
assert (
mode != BINARY_MODE
), "Masking classes is not supported with mode=binary"
assert mode != BINARY_MODE, (

Check warning on line 46 in segmentation_models_pytorch/losses/jaccard.py

View check run for this annotation

Codecov / codecov/patch

segmentation_models_pytorch/losses/jaccard.py#L46

Added line #L46 was not covered by tests
"Masking classes is not supported with mode=binary"
)
classes = to_tensor(classes, dtype=torch.long)

self.classes = classes
Expand Down
4 changes: 2 additions & 2 deletions tests/encoders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading