Skip to content

Commit

Permalink
Enable Ruff pyupgrade (UP) rules (#2146)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSullivan7 authored Mar 25, 2024
2 parents 3d59e0c + 33c4325 commit d0b5a3b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ repos:
args: [--ignore-missing-imports]
additional_dependencies: [types-docutils, types-PyYAML, types-requests]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.3
hooks:
- id: ruff
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ dependencies:
- pyinstaller==6.1.*
- sarepy=2020.07 # For building old docs
- make==4.3
- ruff=0.3.2
- ruff=0.3.3
- pre-commit==3.5.*

6 changes: 3 additions & 3 deletions mantidimaging/core/operations/rebin/rebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from functools import partial
from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING

import numpy as np
from skimage.transform import resize
Expand Down Expand Up @@ -45,7 +45,7 @@ def filter_func(images: ImageStack, rebin_param=0.5, mode=None, progress=None) -
"""
if isinstance(rebin_param, tuple):
new_shape = rebin_param
elif isinstance(rebin_param, (int, float)):
elif isinstance(rebin_param, (int | float)):
current_shape = images.data.shape[1:]
new_shape = (int(current_shape[0] * rebin_param), int(current_shape[1] * rebin_param))
else:
Expand All @@ -60,7 +60,7 @@ def filter_func(images: ImageStack, rebin_param=0.5, mode=None, progress=None) -
return images

@staticmethod
def compute_function(i: int, arrays: List[np.ndarray], params: dict):
def compute_function(i: int, arrays: list[np.ndarray], params: dict):
array = arrays[0]
output = arrays[1]
new_shape = params['new_shape']
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ line-length = 120
target-version = "py310"

[tool.ruff.lint]
select = ["E", "W", "F", "B", "FA", "C4", "NPY"]
fixable = []
select = ["F", "E", "W", "UP", "B", "C4", "FA", "NPY"]
fixable = ["UP"]
ignore = ["UP014"]

0 comments on commit d0b5a3b

Please sign in to comment.