diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f2a4f31..d5710b37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: exclude: setup.cfg - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black @@ -55,13 +55,13 @@ repos: - id: rst-inline-touching-normal # detect mistake of inline code touching normal text in rst - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 + rev: v3.9.0 hooks: - id: pyupgrade args: ['--py37-plus', '--keep-runtime-typing'] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.3.0 + rev: v2.4.0 hooks: - id: setup-cfg-fmt args: ['--include-version-classifiers'] @@ -72,7 +72,7 @@ repos: - id: doc8 - repo: https://github.com/PyCQA/docformatter - rev: v1.7.3 + rev: v1.7.5 hooks: - id: docformatter diff --git a/setup.cfg b/setup.cfg index ed4139e2..02944014 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,6 @@ classifiers = Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -51,7 +50,7 @@ install_requires = torch>=1.1 tqdm typer[all] -python_requires = >=3.7 +python_requires = >=3.8 include_package_data = True zip_safe = False diff --git a/src/torchio/data/image.py b/src/torchio/data/image.py index 4b3e387f..4429a108 100644 --- a/src/torchio/data/image.py +++ b/src/torchio/data/image.py @@ -142,11 +142,9 @@ def __init__( if type is None: warnings.warn( - ( - 'Not specifying the image type is deprecated and will be' - ' mandatory in the future. You can probably use' - ' tio.ScalarImage or tio.LabelMap instead' - ), + 'Not specifying the image type is deprecated and will be' + ' mandatory in the future. You can probably use' + ' tio.ScalarImage or tio.LabelMap instead', DeprecationWarning, stacklevel=2, ) diff --git a/src/torchio/data/queue.py b/src/torchio/data/queue.py index 4a4bc6d6..fb30937f 100644 --- a/src/torchio/data/queue.py +++ b/src/torchio/data/queue.py @@ -215,10 +215,8 @@ def __init__( if self.shuffle_subjects and self.subject_sampler is not None: raise ValueError( - ( - 'The flag shuffle_subjects cannot be set' - ' when a subject sampler is passed' - ), + 'The flag shuffle_subjects cannot be set' + ' when a subject sampler is passed', ) def __len__(self): diff --git a/src/torchio/transforms/augmentation/intensity/random_labels_to_image.py b/src/torchio/transforms/augmentation/intensity/random_labels_to_image.py index 6a700a16..5e4a0a6a 100644 --- a/src/torchio/transforms/augmentation/intensity/random_labels_to_image.py +++ b/src/torchio/transforms/augmentation/intensity/random_labels_to_image.py @@ -205,10 +205,8 @@ def parse_gaussian_parameter( min_value, max_value = nums_range if min_value > max_value: raise ValueError( - ( - f'If {name} is a sequence, the second value must be' - f' equal or greater than the first, not {nums_range}' - ), + f'If {name} is a sequence, the second value must be' + f' equal or greater than the first, not {nums_range}', ) return min_value, max_value diff --git a/src/torchio/transforms/transform.py b/src/torchio/transforms/transform.py index 14ca125d..13b85461 100644 --- a/src/torchio/transforms/transform.py +++ b/src/torchio/transforms/transform.py @@ -281,32 +281,24 @@ def _parse_range( if isinstance(nums_range, numbers.Number): # single number given if nums_range < 0: raise ValueError( - ( - f'If {name} is a single number,' - f' it must be positive, not {nums_range}' - ), + f'If {name} is a single number,' + f' it must be positive, not {nums_range}', ) if min_constraint is not None and nums_range < min_constraint: raise ValueError( - ( - f'If {name} is a single number, it must be greater' - f' than {min_constraint}, not {nums_range}' - ), + f'If {name} is a single number, it must be greater' + f' than {min_constraint}, not {nums_range}', ) if max_constraint is not None and nums_range > max_constraint: raise ValueError( - ( - f'If {name} is a single number, it must be smaller' - f' than {max_constraint}, not {nums_range}' - ), + f'If {name} is a single number, it must be smaller' + f' than {max_constraint}, not {nums_range}', ) if type_constraint is not None: if not isinstance(nums_range, type_constraint): raise ValueError( - ( - f'If {name} is a single number, it must be of' - f' type {type_constraint}, not {nums_range}' - ), + f'If {name} is a single number, it must be of' + f' type {type_constraint}, not {nums_range}', ) min_range = -nums_range if min_constraint is None else nums_range return (min_range, nums_range) @@ -315,10 +307,8 @@ def _parse_range( min_value, max_value = nums_range # type: ignore[misc] except (TypeError, ValueError): raise ValueError( - ( - f'If {name} is not a single number, it must be' - f' a sequence of len 2, not {nums_range}' - ), + f'If {name} is not a single number, it must be' + f' a sequence of len 2, not {nums_range}', ) min_is_number = isinstance(min_value, numbers.Number) @@ -329,26 +319,20 @@ def _parse_range( if min_value > max_value: raise ValueError( - ( - f'If {name} is a sequence, the second value must be' - f' equal or greater than the first, but it is {nums_range}' - ), + f'If {name} is a sequence, the second value must be' + f' equal or greater than the first, but it is {nums_range}', ) if min_constraint is not None and min_value < min_constraint: raise ValueError( - ( - f'If {name} is a sequence, the first value must be greater' - f' than {min_constraint}, but it is {min_value}' - ), + f'If {name} is a sequence, the first value must be greater' + f' than {min_constraint}, but it is {min_value}', ) if max_constraint is not None and max_value > max_constraint: raise ValueError( - ( - f'If {name} is a sequence, the second value must be' - f' smaller than {max_constraint}, but it is {max_value}' - ), + f'If {name} is a sequence, the second value must be' + f' smaller than {max_constraint}, but it is {max_value}', ) if type_constraint is not None: @@ -356,10 +340,8 @@ def _parse_range( max_type_ok = isinstance(max_value, type_constraint) if not min_type_ok or not max_type_ok: raise ValueError( - ( - f'If "{name}" is a sequence, its values must be of' - f' type "{type_constraint}", not "{type(nums_range)}"' - ), + f'If "{name}" is a sequence, its values must be of' + f' type "{type_constraint}", not "{type(nums_range)}"', ) return nums_range # type: ignore[return-value]