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

add py.typed marker file for type checking in mypy #808

Merged
merged 1 commit into from
Jan 30, 2022

Conversation

jcreinhold
Copy link
Contributor

Fixes #807.

Description

This PR adds a py.typed marker file so that end users can make use of type annotations in torchio in mypy.

This PR doesn't fix the current state of the type annotations which need to be reworked to work properly with mypy.

I tested this implementation in another project using torchio, and mypy recognizes the py.typed marker file.

Checklist

  • I have read the CONTRIBUTING docs and have a developer setup (especially important are pre-commitand pytest)
  • Non-breaking change (would not break existing functionality)
  • Breaking change (would cause existing functionality to change)
  • Tests added or modified to cover the changes (Not relevant)
  • Integration tests passed locally by running pytest
  • In-line docstrings updated (Not relevant)
  • Documentation updated, tested running make html inside the docs/ folder (Not relevant)
  • This pull request is ready to be reviewed
  • If the PR is ready and there are multiple commits, I have squashed them and force-pushed (Not relevant)

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #808 (8263ad4) into main (1c217d8) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #808   +/-   ##
=======================================
  Coverage   93.87%   93.87%           
=======================================
  Files          72       72           
  Lines        4524     4524           
=======================================
  Hits         4247     4247           
  Misses        277      277           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c217d8...8263ad4. Read the comment docs.

@fepegar fepegar merged commit 989ae03 into fepegar:main Jan 30, 2022
@fepegar
Copy link
Owner

fepegar commented Jan 30, 2022

Awesome. Many thanks for your contribution, @jcreinhold. May I add you to the list of contributors?

I agree that typing hints in TorchIO are a bit messy. I suppose part of the reason is that I didn't add them since the beginning, and the library was not created to be shared initially. Also, I don't know much about the topic. It would be great to improve typing in the library, and your help would be much appreciated!

@fepegar
Copy link
Owner

fepegar commented Jan 30, 2022

For reference, this is currently the output of mypy torchio:

torchio/data/io.py:102: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[int, int, int, int]")
torchio/data/io.py:396: error: Incompatible types in assignment (expression has type "Tuple[Any, Any, Any, Any, Any, Any, Any, Any, Any]", variable has type "Tuple[Any, Any, Any, Any]")
torchio/utils.py:52: error: Item "PathLike[Any]" of "Union[PathLike[Any], Sequence[Union[str, PathLike[Any]]]]" has no attribute "__iter__" (not iterable)
torchio/utils.py:168: error: Cannot infer type argument 1 of "copyfileobj"
torchio/utils.py:300: error: Missing return statement
torchio/utils.py:307: error: Incompatible return value type (got "str", expected "Optional[Path]")
torchio/utils.py:334: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "Path")
torchio/data/image.py:291: error: Incompatible return value type (got "Union[Tuple[float, float, float, float], Tuple[float, float, float, float, float, float, float, float, float]]", expected "Tuple[float, float, float, float, float, float, float, float, float]")
torchio/data/image.py:297: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[float, float, float]")
torchio/data/image.py:302: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[float, float, float]")
torchio/data/image.py:428: error: Item "PathLike[Any]" of "Union[PathLike[Any], Sequence[Union[str, PathLike[Any]]]]" has no attribute "__iter__" (not iterable)
torchio/data/image.py:430: error: Argument 1 to "_parse_single_path" of "Image" has incompatible type "Union[PathLike[Any], Sequence[Union[str, PathLike[Any]]]]"; expected "Union[str, PathLike[Any]]"
torchio/data/image.py:785: error: Incompatible return value type (got "Union[int, float, bool]", expected "int")
torchio/data/subject.py:54: error: Argument 1 to "_parse_images" of "Subject" has incompatible type "List[Image]"; expected "List[Tuple[str, Image]]"
torchio/data/subject.py:56: error: Need type annotation for "applied_transforms" (hint: "applied_transforms: List[<type>] = ...")
torchio/data/subject.py:201: error: Incompatible return value type (got "Transform", expected "Compose")
torchio/data/subject.py:212: error: Item "Image" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "clear_history"
torchio/data/subject.py:212: error: Item "Tensor" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "clear_history"
torchio/data/subject.py:212: error: Item "ndarray[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "clear_history"
torchio/data/subject.py:212: error: Item "Dict[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "clear_history"
torchio/data/subject.py:213: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/data_parser.py:120: error: Argument 1 to "_get_subject_from_tensor" of "DataParser" has incompatible type "Union[Tensor, ndarray[Any, Any]]"; expected "Tensor"
torchio/data/dataset.py:97: error: The erased type of self "torchio.data.dataset.SubjectsDataset" is not a supertype of its class "Type[torchio.data.dataset.SubjectsDataset]"
torchio/data/dataset.py:105: error: "SubjectsDataset" not callable
torchio/data/sampler/sampler.py:40: error: Argument 3 to "crop" of "PatchSampler" has incompatible type "ndarray[Any, Any]"; expected "Tuple[int, int, int]"
torchio/data/sampler/sampler.py:51: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/sampler.py:52: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/sampler.py:54: error: "Tuple[int, int, int]" has no attribute "tolist"
torchio/data/sampler/sampler.py:54: error: "Tuple[int, int, int, int, int, int]" has no attribute "tolist"
torchio/data/sampler/sampler.py:67: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/sampler.py:68: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Union[int, Tuple[int, int, int]]")
torchio/data/sampler/sampler.py:70: error: Argument 1 to "len" has incompatible type "Union[int, Tuple[int, int, int]]"; expected "Sized"
torchio/data/sampler/sampler.py:71: error: No overload variant of "__add__" of "tuple" matches argument type "int"
torchio/data/sampler/sampler.py:71: note: Possible overload variants:
torchio/data/sampler/sampler.py:71: note:     def __add__(self, Tuple[int, ...]) -> Tuple[int, ...]
torchio/data/sampler/sampler.py:71: note:     def __add__(self, Tuple[Any, ...]) -> Tuple[Any, ...]
torchio/data/sampler/sampler.py:71: note: Right operand is of type "Union[int, Tuple[int, int, int]]"
torchio/data/sampler/sampler.py:72: error: "Tuple[int, int, int]" has no attribute "tolist"
torchio/data/sampler/sampler.py:76: error: Argument 1 to "Crop" has incompatible type "Union[Tuple[Any, Any], Tuple[]]"; expected "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]"
torchio/transforms/transform.py:282: error: "builtins.int" object is not iterable
torchio/transforms/transform.py:282: error: "builtins.float" object is not iterable
torchio/transforms/transform.py:321: error: Incompatible return value type (got "Union[Union[int, float], Tuple[Union[int, float], Union[int, float]]]", expected "Tuple[Union[int, float], Union[int, float]]")
torchio/transforms/transform.py:366: error: Incompatible return value type (got "Tuple[ndarray[Any, Any], ndarray[Any, Any]]", expected "Tuple[Tensor, ndarray[Any, Any]]")
torchio/transforms/transform.py:408: error: Incompatible return value type (got "None", expected "Tuple[int, int, int, int, int, int]")
torchio/transforms/transform.py:410: error: Incompatible types in assignment (expression has type "Tuple[int, ...]", variable has type "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]")
torchio/transforms/transform.py:410: error: Argument 1 to "tuple" has incompatible type "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]"; expected "Iterable[int]"
torchio/transforms/transform.py:412: error: Incompatible types in assignment (expression has type "Tuple[Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]]", variable has type "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]")
torchio/transforms/transform.py:415: error: Item "int" of "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]" has no attribute "__iter__" (not iterable)
torchio/transforms/transform.py:422: error: Incompatible types in assignment (expression has type "Tuple[int, ...]", variable has type "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]")
torchio/transforms/transform.py:422: error: Item "int" of "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]" has no attribute "__iter__" (not iterable)
torchio/transforms/transform.py:423: error: Argument 1 to "len" has incompatible type "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]"; expected "Sized"
torchio/transforms/transform.py:425: error: Incompatible return value type (got "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]", expected "Tuple[int, int, int, int, int, int]")
torchio/transforms/transform.py:427: error: Incompatible return value type (got "Union[int, Tuple[int, ...]]", expected "Tuple[int, int, int, int, int, int]")
torchio/transforms/transform.py:429: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[int, int, int, int, int, int]")
torchio/transforms/transform.py:470: error: Argument 1 to "get_mask_from_bounds" of "Transform" has incompatible type "Union[str, int, Tuple[int, int, int], Tuple[int, int, int, int, int, int]]"; expected "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]"
torchio/data/sampler/weighted.py:66: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tensor")
torchio/data/sampler/weighted.py:68: error: Argument 1 to "get_cumulative_distribution_function" of "WeightedSampler" has incompatible type "Tensor"; expected "ndarray[Any, Any]"
torchio/data/sampler/weighted.py:72: error: Argument 2 to "extract_patch" of "WeightedSampler" has incompatible type "Tensor"; expected "ndarray[Any, Any]"
torchio/data/sampler/weighted.py:72: error: Argument 3 to "extract_patch" of "WeightedSampler" has incompatible type "Tuple[ndarray[Any, Any], ndarray[Any, Any]]"; expected "ndarray[Any, Any]"
torchio/data/sampler/weighted.py:104: error: Argument 2 to "clear_probability_borders" of "WeightedSampler" has incompatible type "ndarray[Any, Any]"; expected "Union[int, Tuple[int, int, int]]"
torchio/data/sampler/weighted.py:147: error: Unsupported operand types for // ("Tuple[int, int, int]" and "int")
torchio/data/sampler/weighted.py:147: note: Left operand is of type "Union[int, Tuple[int, int, int]]"
torchio/data/sampler/weighted.py:148: error: Unsupported operand types for - ("Tuple[int, int, int]" and "int")
torchio/data/sampler/weighted.py:148: note: Left operand is of type "Union[int, Tuple[int, int, int]]"
torchio/data/sampler/weighted.py:149: error: "builtins.int" object is not iterable
torchio/data/sampler/weighted.py:172: error: Incompatible return value type (got "ndarray[Any, Any]", expected "Tuple[ndarray[Any, Any], ndarray[Any, Any]]")
torchio/data/sampler/weighted.py:174: error: Signature of "extract_patch" incompatible with supertype "PatchSampler"
torchio/data/sampler/weighted.py:181: error: Argument 2 to "crop" of "PatchSampler" has incompatible type "ndarray[Any, Any]"; expected "Tuple[int, int, int]"
torchio/data/sampler/weighted.py:181: error: Argument 3 to "crop" of "PatchSampler" has incompatible type "ndarray[Any, Any]"; expected "Tuple[int, int, int]"
torchio/data/sampler/uniform.py:31: error: Argument 2 to "extract_patch" of "PatchSampler" has incompatible type "ndarray[Any, Any]"; expected "Tuple[int, int, int]"
torchio/data/sampler/grid.py:76: error: Argument 1 to "_pad" of "GridSampler" has incompatible type "Optional[Subject]"; expected "Subject"
torchio/data/sampler/grid.py:94: error: Argument 1 to "Pad" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]"
torchio/data/sampler/grid.py:95: error: Incompatible types in assignment (expression has type "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", variable has type "Subject")
torchio/data/sampler/grid.py:102: error: Argument 1 to "_parse_sizes" of "GridSampler" has incompatible type "*Tuple[Any, ndarray[Any, Any], ndarray[Any, Any]]"; expected "Tuple[int, int, int]"
torchio/data/sampler/grid.py:103: error: Argument 1 to "_get_patches_locations" of "GridSampler" has incompatible type "*Tuple[Any, ndarray[Any, Any], ndarray[Any, Any]]"; expected "Tuple[int, int, int]"
torchio/data/sampler/grid.py:105: error: Signature of "_generate_patches" incompatible with supertype "PatchSampler"
torchio/data/sampler/grid.py:111: error: Argument 1 to "_parse_sizes" of "GridSampler" has incompatible type "*Tuple[Any, ndarray[Any, Any], ndarray[Any, Any]]"; expected "Tuple[int, int, int]"
torchio/data/sampler/grid.py:112: error: Argument 1 to "_get_patches_locations" of "GridSampler" has incompatible type "*Tuple[Any, ndarray[Any, Any], ndarray[Any, Any]]"; expected "Tuple[int, int, int]"
torchio/data/sampler/grid.py:123: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/grid.py:124: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/grid.py:125: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Tuple[int, int, int]")
torchio/data/sampler/grid.py:138: error: Unsupported operand types for % ("Tuple[int, int, int]" and "int")
torchio/transforms/lambda_transform.py:39: error: Incompatible types in assignment (expression has type "Tuple[str, str]", variable has type "Tuple[]")
torchio/transforms/intensity_transform.py:32: error: Need type annotation for "name"
torchio/data/sampler/label.py:66: error: Argument "probability_map" to "__init__" of "WeightedSampler" has incompatible type "Optional[str]"; expected "str"
torchio/transforms/preprocessing/label/remap_labels.py:61: error: Incompatible types in assignment (expression has type "Tuple[str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/label/one_hot.py:18: error: Incompatible types in assignment (expression has type "Tuple[str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/clamp.py:46: error: Incompatible types in assignment (expression has type "Tuple[str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/clamp.py:50: error: Argument 1 to "apply_clamp" of "Clamp" has incompatible type "Image"; expected "ScalarImage"
torchio/transforms/preprocessing/label/remove_labels.py:58: error: Incompatible types in assignment (expression has type "Tuple[str, str, str]", variable has type "Tuple[]")
torchio/data/inference/aggregator.py:88: error: Incompatible return value type (got "Tuple[List[Any], ndarray[Any, Any]]", expected "Tuple[Union[Tensor, ndarray[Any, Any]], ndarray[Any, Any]]")
torchio/data/inference/aggregator.py:94: error: Incompatible types in assignment (expression has type "Tensor", variable has type "None")
torchio/data/inference/aggregator.py:104: error: Incompatible types in assignment (expression has type "Tensor", variable has type "None")
torchio/data/inference/aggregator.py:130: error: Argument 2 to "crop_batch" of "GridAggregator" has incompatible type "Tensor"; expected "ndarray[Any, Any]"
torchio/data/inference/aggregator.py:135: error: Unsupported target for indexed assignment ("None")
torchio/data/inference/aggregator.py:144: error: Value of type "None" is not indexable
torchio/data/inference/aggregator.py:144: error: Unsupported target for indexed assignment ("None")
torchio/data/inference/aggregator.py:149: error: Value of type "None" is not indexable
torchio/data/inference/aggregator.py:149: error: Unsupported target for indexed assignment ("None")
torchio/data/inference/aggregator.py:157: error: "None" has no attribute "dtype"
torchio/data/inference/aggregator.py:163: error: "None" has no attribute "type"
torchio/data/inference/aggregator.py:169: error: Argument 1 to "true_divide" has incompatible type "None"; expected "Union[Tensor, Union[int, float, bool]]"
torchio/data/inference/aggregator.py:169: error: Argument 2 to "true_divide" has incompatible type "None"; expected "Union[Tensor, Union[int, float, bool]]"
torchio/data/inference/aggregator.py:171: error: Incompatible types in assignment (expression has type "None", variable has type "Tensor")
torchio/data/inference/aggregator.py:176: error: Argument 1 to "Crop" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Union[int, Tuple[int, int, int], Tuple[int, int, int, int, int, int], None]"
torchio/data/inference/aggregator.py:177: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Tensor")
torchio/transforms/preprocessing/spatial/resize.py:44: error: Incompatible types in assignment (expression has type "Tuple[str, str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/spatial/resize.py:65: error: Item "Tensor" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:65: error: Item "ndarray[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:65: error: Item "Dict[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:67: error: Item "Tensor" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:67: error: Item "ndarray[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:67: error: Item "Dict[Any, Any]" of "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]" has no attribute "spatial_shape"
torchio/transforms/preprocessing/spatial/resize.py:71: error: Argument 1 to "CropOrPad" has incompatible type "ndarray[Any, Any]"; expected "Union[int, Tuple[int, int, int], None]"
torchio/transforms/preprocessing/spatial/resize.py:73: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/preprocessing/spatial/resample.py:92: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/spatial/resample.py:103: error: Need type annotation for "result"
torchio/transforms/preprocessing/spatial/resample.py:154: error: Argument 1 to "check_affine_key_presence" of "Resample" has incompatible type "Optional[str]"; expected "str"
torchio/transforms/preprocessing/spatial/resample.py:178: error: Argument 1 to "check_affine" of "Resample" has incompatible type "Optional[str]"; expected "str"
torchio/transforms/preprocessing/spatial/resample.py:190: error: Argument 2 to "_set_resampler_reference" of "Resample" has incompatible type "Union[Union[float, Tuple[float, float, float]], str, Path, Image, None]"; expected "Union[Union[float, Tuple[float, float, float]], Union[str, PathLike[Any]], Image]"
torchio/transforms/preprocessing/spatial/resample.py:242: error: Unpacking a string is disallowed
torchio/transforms/preprocessing/spatial/resample.py:243: error: Argument 1 to "len" has incompatible type "Iterable[Any]"; expected "Sized"
torchio/transforms/preprocessing/spatial/pad.py:65: error: Incompatible types in assignment (expression has type "Tuple[str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/spatial/ensure_shape_multiple.py:129: error: "object" not callable
torchio/transforms/preprocessing/spatial/ensure_shape_multiple.py:132: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:155: error: Incompatible return value type (got "Tuple[int, ...]", expected "Tuple[int, int, int, int, int, int]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:167: error: Incompatible types in assignment (expression has type "None", variable has type "Tuple[int, int, int, int, int, int]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:173: error: Incompatible types in assignment (expression has type "None", variable has type "Tuple[int, int, int, int, int, int]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:203: error: Argument 4 to "get_mask_from_masking_method" of "Transform" has incompatible type "Optional[Sequence[int]]"; expected "Optional[List[Any]]"
torchio/transforms/preprocessing/spatial/crop_or_pad.py:260: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "List[int]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:261: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "List[Any]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:262: error: "List[int]" has no attribute "tolist"
torchio/transforms/preprocessing/spatial/crop_or_pad.py:262: error: "List[int]" has no attribute "any"
torchio/transforms/preprocessing/spatial/crop_or_pad.py:263: error: "List[Any]" has no attribute "tolist"
torchio/transforms/preprocessing/spatial/crop_or_pad.py:263: error: "List[Any]" has no attribute "any"
torchio/transforms/preprocessing/spatial/crop_or_pad.py:264: error: Incompatible return value type (got "Tuple[Optional[Tuple[Any, ...]], Optional[Tuple[Any, ...]]]", expected "Tuple[Optional[Tuple[int, int, int, int, int, int]], Optional[Tuple[int, int, int, int, int, int]]]")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:271: error: Incompatible types in assignment (expression has type "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", variable has type "Subject")
torchio/transforms/preprocessing/spatial/crop_or_pad.py:273: error: Incompatible types in assignment (expression has type "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", variable has type "Subject")
torchio/transforms/preprocessing/spatial/crop.py:39: error: Incompatible types in assignment (expression has type "Tuple[str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/spatial/copy_affine.py:71: error: Incompatible types in assignment (expression has type "Tuple[str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/z_normalization.py:21: error: Incompatible types in assignment (expression has type "Tuple[str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/z_normalization.py:48: error: Incompatible return value type (got "None", expected "Tensor")
torchio/transforms/preprocessing/intensity/rescale.py:59: error: Incompatible types in assignment (expression has type "Tuple[str, str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/rescale.py:88: error: No overload variant of "clip" matches argument types "Any", "Any", "Any"
torchio/transforms/preprocessing/intensity/rescale.py:88: note: Possible overload variants:
torchio/transforms/preprocessing/intensity/rescale.py:88: note:     def clip(a: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], Union[Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]], Union[bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]]], a_min: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], Union[Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]], Union[bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]]], a_max: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], _SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]], None], out: Optional[ndarray[Any, Any]] = ..., **kwargs: Any) -> Any
torchio/transforms/preprocessing/intensity/rescale.py:88: note:     def clip(a: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], Union[Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]], Union[bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]]], a_min: None, a_max: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], Union[Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]], Union[bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]]], out: Optional[ndarray[Any, Any]] = ..., **kwargs: Any) -> Any
torchio/transforms/preprocessing/intensity/mask.py:60: error: Argument 4 to "get_mask_from_masking_method" of "Transform" has incompatible type "Optional[Sequence[int]]"; expected "Optional[List[Any]]"
torchio/transforms/preprocessing/intensity/mask.py:62: error: Argument 1 to "apply_masking" of "Mask" has incompatible type "Image"; expected "LabelMap"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:57: error: Incompatible types in assignment (expression has type "Tuple[str, str]", variable has type "Tuple[]")
torchio/transforms/preprocessing/intensity/histogram_standardization.py:92: error: Argument "mask" to "normalize" has incompatible type "Tensor"; expected "Optional[ndarray[Any, Any]]"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:156: error: Argument 1 to "len" has incompatible type "Union[Sequence[Union[str, PathLike[Any]]], str, PathLike[Any], None]"; expected "Sized"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:158: error: Argument 1 to "len" has incompatible type "Union[Sequence[Union[str, PathLike[Any]]], str, PathLike[Any], None]"; expected "Sized"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:165: error: Argument 1 to "_get_percentiles" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Tuple[float, float]"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:175: error: Value of type "Union[Sequence[Union[str, PathLike[Any]]], PathLike[Any]]" is not indexable
torchio/transforms/preprocessing/intensity/histogram_standardization.py:183: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "List[Any]")
torchio/transforms/preprocessing/intensity/histogram_standardization.py:184: error: Argument 1 to "_get_average_mapping" has incompatible type "List[Any]"; expected "ndarray[Any, Any]"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:260: error: Argument 1 to "_standardize_cutoff" has incompatible type "Tuple[float, float]"; expected "ndarray[Any, Any]"
torchio/transforms/preprocessing/intensity/histogram_standardization.py:262: error: Argument 1 to "_get_percentiles" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Tuple[float, float]"
torchio/transforms/augmentation/composition.py:47: error: Incompatible types in assignment (expression has type "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", variable has type "Subject")
torchio/transforms/augmentation/composition.py:110: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/augmentation/spatial/random_flip.py:61: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:132: error: Argument 1 to "_parse_num_control_points" has incompatible type "Tuple[Union[int, float], ...]"; expected "Tuple[int, int, int]"
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:134: error: Argument 1 to "_parse_max_displacement" has incompatible type "Tuple[Union[int, float], ...]"; expected "Tuple[float, float, float]"
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:177: error: Argument 1 to "get_params" of "RandomElasticDeformation" has incompatible type "Tuple[Union[int, float], ...]"; expected "Tuple[int, int, int]"
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:178: error: Argument 2 to "get_params" of "RandomElasticDeformation" has incompatible type "Tuple[Union[int, float], ...]"; expected "Tuple[float, float, float]"
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:191: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:222: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str]", variable has type "Tuple[]")
torchio/transforms/augmentation/spatial/random_elastic_deformation.py:297: error: Argument 2 to "parse_free_form_transform" of "ElasticDeformation" has incompatible type "Tuple[float, float, float]"; expected "Sequence[Tuple[int, int, int]]"
torchio/transforms/augmentation/spatial/random_anisotropy.py:69: error: No overload variant of "__getitem__" of "tuple" matches argument type "Tensor"
torchio/transforms/augmentation/spatial/random_anisotropy.py:69: note: Possible overload variants:
torchio/transforms/augmentation/spatial/random_anisotropy.py:69: note:     def __getitem__(self, int) -> int
torchio/transforms/augmentation/spatial/random_anisotropy.py:69: note:     def __getitem__(self, slice) -> Tuple[int, ...]
torchio/transforms/augmentation/spatial/random_anisotropy.py:71: error: Incompatible return value type (got "Tuple[Any, Any]", expected "List[bool]")
torchio/transforms/augmentation/spatial/random_anisotropy.py:104: error: Argument "target" to "Resample" has incompatible type "Tuple[Any, ...]"; expected "Union[Union[float, Tuple[float, float, float]], str, Path, Image, None]"
torchio/transforms/augmentation/spatial/random_anisotropy.py:111: error: Argument "target" to "Resample" has incompatible type "Tuple[Tuple[int, int, int], ndarray[Any, Any]]"; expected "Union[Union[float, Tuple[float, float, float]], str, Path, Image, None]"
torchio/transforms/augmentation/spatial/random_anisotropy.py:116: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/augmentation/spatial/random_affine.py:172: error: Incompatible return value type (got "Union[Subject, Image, Tensor, ndarray[Any, Any], Any, Dict[Any, Any], Any]", expected "Subject")
torchio/transforms/augmentation/spatial/random_affine.py:251: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str, str, str, str, str]", variable has type "Tuple[]")
torchio/transforms/augmentation/spatial/random_affine.py:269: error: Incompatible types in assignment (expression has type "ndarray[Any, Any]", variable has type "Sequence[float]")
torchio/transforms/augmentation/spatial/random_affine.py:290: error: Argument 1 to "ras_to_lps" has incompatible type "Sequence[float]"; expected "ndarray[Any, Any]"
torchio/transforms/augmentation/spatial/random_affine.py:369: error: Incompatible types in assignment (expression has type "Union[str, float]", variable has type "int")
torchio/transforms/augmentation/intensity/random_swap.py:61: error: Argument 1 to "get_random_indices_from_shape" has incompatible type "Size"; expected "Tuple[int, int, int]"
torchio/transforms/augmentation/intensity/random_swap.py:62: error: Argument 2 to "get_random_indices_from_shape" has incompatible type "ndarray[Any, Any]"; expected "Tuple[int, int, int]"
torchio/transforms/augmentation/intensity/random_swap.py:62: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
torchio/transforms/augmentation/intensity/random_labels_to_image.py:123: error: Syntax error in type annotation
torchio/transforms/augmentation/intensity/random_labels_to_image.py:123: note: Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn)
torchio/transforms/augmentation/intensity/random_blur.py:6: error: Skipping analyzing "scipy.ndimage": found module but no type hints or library stubs
torchio/transforms/augmentation/intensity/random_blur.py:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
torchio/transforms/augmentation/intensity/random_blur.py:6: error: Skipping analyzing "scipy": found module but no type hints or library stubs
torchio/visualization.py:15: error: Skipping analyzing "matplotlib": found module but no type hints or library stubs
torchio/visualization.py:16: error: Skipping analyzing "matplotlib.pyplot": found module but no type hints or library stubs
Found 177 errors in 39 files (checked 95 source files)

@jcreinhold jcreinhold deleted the 807-py-typed branch January 30, 2022 15:57
@jcreinhold
Copy link
Contributor Author

Awesome. Many thanks for your contribution, @jcreinhold. May I add you to the list of contributors?

Sure! That'd be great

I agree that typing hints in TorchIO are a bit messy. I suppose part of the reason is that I didn't add them since the beginning, and the library was not created to be shared initially. Also, I don't know much about the topic. It would be great to improve typing in the library, and your help would be much appreciated!

Sometimes adding them from the beginning makes it more difficult to update them later to reflect what the project actually requires. I've grafted type annotations on to many of my research and work projects now, and I can start going through torchio function by function and updating them to pass mypy inspection. mypy has caught a good number of errors in my code, and proper type annotations make development much easier in a modern IDE (IMO), so I think it'd be worth the effort.

Since this would change a good number of files (39 it looks like, although some of the errors might be fixed by fixing the type issue elsewhere), I could do the following:

  1. Make a mypy feature branch
  2. Define the least strict base types the project requires
  3. Fix the mypy issues in one function
  4. Commit the changes
  5. Repeat 3-4 until no more mypy errors
  6. Submit a PR

Alternatively, I could make a mypy-modulename feature branch and submit a PR for each module (e.g., at the level of torchio/data/image.py or torchio/data). It might get a bit tedious, but it'd avoid a giant PR; however, type annotations are very entangled, so I'm not sure how effective that workflow would be at eliminating errors from the project, but I could try and see how it goes and update you if it's untenable.

I'd avoid changing any actual functionality, although there are likely to be be some bugs caught while going through the process. If I find a potential error, I'd just raise an issue instead of correcting it.

Would some workflow like the above make sense?

@fepegar
Copy link
Owner

fepegar commented Jan 30, 2022

That sounds great! If a single PR makes your life easier than the individual ones, I suggest following that route. Thanks a lot for working on this!

@all-contributors please add @jcreinhold for code

@allcontributors
Copy link
Contributor

@fepegar

I've put up a pull request to add @jcreinhold! 🎉

justusschock added a commit to justusschock/torchio that referenced this pull request Jun 28, 2022
Use type of current instance instead of hardcoded subject type

fix copy behavior

Stop running some unstable tests on CI (fepegar#796)

* Print output messages during testing

* Skip MedMNIST tests on GitHub Actions

* Fix AttributeError

* Add reason for skipping test

Add support to specify the interpolation type for label images (fepegar#791)

* Add label_interpolation option in spatial transforms and augmentations

* Add label_interpolation option in spatial transforms and augmentations

* Adds missing backtick

* update docs 782

* Minor docs edits

Co-authored-by: Fernando Pérez-García <[email protected]>

docs: add snavalm as a contributor for code (fepegar#802)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Bump version: 0.18.71 → 0.18.72

Add py.typed marker file for type checking (fepegar#808)

docs: add jcreinhold as a contributor for code (fepegar#809)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Bump version: 0.18.72 → 0.18.73

Fix overlapping in patches aggregator (fepegar#832)

Bump version: 0.18.73 → 0.18.74

Update announcement

docs: add Hsuxu as a contributor for bug (fepegar#833)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Add check for shapes of input batch and output location

Add support for torch >= 1.11 (fepegar#838)

* added support for pytorch>=1.11.0

* Replace type with isinstance

Co-authored-by: Fernando Pérez-García <[email protected]>

Bump version: 0.18.74 → 0.18.75

docs: add snipdome as a contributor for bug (fepegar#839)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Remove redundant tests in GitHub actions (fepegar#850)

Fix new SimpleITK release breaking tests (fepegar#852)

Bump version: 0.18.75 → 0.18.76

Disable fail-fast in CI matrix strategy

Fix wrong mapping in SequentialLabels transform (fepegar#841)

docs: add iamSmallY as a contributor for bug (fepegar#855)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Fix SimpleITK version in docs requirements

Fix examples format in docstrings

Improve documentation and tests for label transforms (fepegar#857)

* Improve documentation and tests for label transforms

* Add parametrization with duplicated values in dict

Add example of RandomLabelsToImage

Add example of RandomGamma

Use sphinx-opengraph for documentation

Improve quality of figures from plot directive

[pre-commit.ci] pre-commit autoupdate (fepegar#859)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.0.1 → v4.2.0](pre-commit/pre-commit-hooks@v4.0.1...v4.2.0)
- [github.com/pycqa/flake8: 3.9.2 → 4.0.1](PyCQA/flake8@3.9.2...4.0.1)
- [github.com/asottile/pyupgrade: v2.29.0 → v2.32.0](asottile/pyupgrade@v2.29.0...v2.32.0)

* Fix pre-commit not installing flake8

This commit address the comments by @asottile in
pre-commit-ci/issues#118.

Thanks, @asottile!

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fernando Pérez-García <[email protected]>

Validate arguments of add/remove_image

Return figure in plot_volume function (fepegar#872)

Co-authored-by: Derk <[email protected]>

docs: add guigautier as a contributor for ideas (fepegar#875)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Update flake8 error codes

[pre-commit.ci] pre-commit autoupdate (fepegar#874)

updates:
- [github.com/asottile/pyupgrade: v2.32.0 → v2.32.1](asottile/pyupgrade@v2.32.0...v2.32.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fernando Pérez-García <[email protected]>

Stop upgrading pip in CI (fepegar#877)

Update bug report template

docs: add AyedSamy as a contributor for bug (fepegar#878)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Add tests for Python 3.10 (fepegar#880)

* Add tests for Python 3.10

* Fix Python version in YAML

Use PyTorch to compute Fourier transforms (fepegar#389)

* Use PyTorch for FFT if available

* Make sure tensor in on CPU before calling numpy()

Remove support for Python 3.6 (fepegar#881)

* Remove support for Python 3.6

* Fix Python version

Add support to use different numbers of samples in the queue (fepegar#795)

docs: add jmlipman as a contributor for ideas, code (fepegar#882)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Juan Miguel <[email protected]>

Fix computation of kernels in `Blur` transform (fepegar#861)

* Fix size of Gaussian kernel for blurring

* Fix typo in docstring

Add support to pass label keys for dict input (fepegar#879)

* Add support to pass label keys for dict input

* Add reference to @josegcpa's code

Co-authored-by: josegcpa <[email protected]>

docs: add josegcpa as a contributor for ideas (fepegar#883)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Bump version: 0.18.76 → 0.18.77

Fix support for NiBabel inputs

Remove unnecessary check

Remove error for multichannel NiBabel input

Cover method to print queue memory

Add gallery example for custom resampling transform

docs: add saikhu as a contributor for bug (fepegar#887)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Move package code to `src` directory (fepegar#896)

* Move package to src directory

* Update setup.py

* Update setup.py

* Move requirements

* Include requirements file in MANIFEST.in

* Stop using requirements file

* Fix warning in docs

Remove setup.py script and add pyproject.toml config file (fepegar#898)

* Remove setup.py and add pyproject.toml

* Add version to setup config

* Remove bumpversion config for setup.py

* Fix path to __init__

* Stop removing trailing whitespaces from setup.cfg

See peritus/bumpversion#78

* Update version replacing in bumpversion config

* Fix tox configuration for pyproject.toml

* Add keywords

* Remove requirements file

* Update authors config

Bump version: 0.18.77 → 0.18.78

Enable verbose mode for publishing GHA

Fix version

Fix version not being updated

As it seems that bump2version is not able to modify its own config file.

Add citation file

[pre-commit.ci] pre-commit autoupdate (fepegar#902)

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.3.0](pre-commit/pre-commit-hooks@v4.2.0...v4.3.0)
- [github.com/asottile/pyupgrade: v2.32.1 → v2.34.0](asottile/pyupgrade@v2.32.1...v2.34.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Fix warning in RTD documentation build (fepegar#903)

Add hook for trailing commas (fepegar#904)

* Add hook for trailing commas

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix flake8 issues

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Disable Binder buttons in Sphinx gallery (fepegar#905)

* Disable Binder buttons in Sphinx gallery

* Update RTD config to use pip installation

* Fix extra requirements string

* Add missing doc requirement

Add checks for TOML and YAML files

Add support to mask 4D images with 3D masks (fepegar#908)

* Add failing test

* Add support to mask 4D images with 3D masks

* Improve docstring

Co-authored-by: cbri92 <[email protected]>
Co-authored-by: valabregue <[email protected]>

docs: add cbri92 as a contributor for bug (fepegar#909)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Bump version: 0.18.78 → 0.18.79

Add fftshift to fourier_transform with torch.fft (fepegar#912)

This makes the behavior of fourier_transform and inv_fourier_transform
consistent with earlier versions of torchio. It is also independent of
whether torch or numpy is used to perform the transform.

Solves fepegar#911

docs: add iimog as a contributor for bug (fepegar#913)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

Bump version: 0.18.79 → 0.18.80

Remove incorrect Contributors badge

Stop ignoring some missing imports for mypy

Fix tox running on Python 3.7 only (fepegar#915)

Create dependabot.yml (fepegar#917)

Test all Python versions in Ubuntu only (fepegar#918)

* Test all Python versions in Ubuntu only

* Fix exclusions

Bump actions/setup-python from 2 to 4 (fepegar#919)

Bumps [actions/setup-python](https:/actions/setup-python) from 2 to 4.
- [Release notes](https:/actions/setup-python/releases)
- [Commits](actions/setup-python@v2...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Ignore some files in MANIFEST (fepegar#916)

* Ignore some files in MANIFEST

* Always publish to TestPyPI

* Skip existing TestPyPI versions

Bump actions/checkout from 2 to 3 (fepegar#920)

Bumps [actions/checkout](https:/actions/checkout) from 2 to 3.
- [Release notes](https:/actions/checkout/releases)
- [Changelog](https:/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Update fpg.py

Proper copy of subclass copies

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

fix parenthesis

imports

Fix proper subject subclass copy

old-style type annotations

linting

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Fix proper subject subclass copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add py.typed marker file
2 participants