Skip to content

Commit

Permalink
enable flake8-mypy checks (Project-MONAI#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyli authored May 26, 2020
1 parent bc9f55d commit c88c567
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion monai/transforms/utility/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(
self.intensity_range = intensity_range
self.data_value = data_value
if additional_info is not None:
assert isinstance(additional_info, Callable), "additional_info must be a Callable function."
assert callable(additional_info), "additional_info must be a Callable function."
self.additional_info = additional_info
self.output = None
logging.basicConfig(level=logging.NOTSET)
Expand Down
8 changes: 4 additions & 4 deletions monai/visualize/img2tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def make_animated_gif_summary(
max_out: int = 3,
animation_axes: Sequence[int] = (3,),
image_axes: Sequence[int] = (1, 2),
other_indices: any = None,
other_indices: dict = None,
scale_factor: float = 1,
):
"""Creates an animated gif out of an image tensor in 'CHWD' format and returns Summary.
Expand All @@ -63,7 +63,7 @@ def make_animated_gif_summary(
max_out (int): maximum number of slices to animate through
animation_axes (Sequence[int]): axis to animate on (not currently used)
image_axes (Sequence[int]): axes of image (not currently used)
other_indices (any): (not currently used)
other_indices (dict): (not currently used)
scale_factor (float): amount to multiply values by.
if the image data is between 0 and 1, using 255 for this value will scale it to displayable range
"""
Expand All @@ -83,7 +83,7 @@ def make_animated_gif_summary(
else:
other_ind = other_indices.get(i, 0)
slicing.append(slice(other_ind, other_ind + 1))
image: Union[Tensor, np.array] = image[tuple(slicing)]
image = image[tuple(slicing)]

for it_i in range(min(max_out, list(image.shape)[0])):
one_channel_img: Union[Tensor, np.array] = image[it_i, :, :, :].squeeze(dim=0) if torch.is_tensor(
Expand Down Expand Up @@ -129,7 +129,7 @@ def add_animated_gif_no_channels(
global_step: int = None,
):
"""Creates an animated gif out of an image tensor in 'HWD' format that does not have
a channel dimension and writes it with SummaryWriter. This is similar to the "add_animated_gif"
a channel dimension and writes it with SummaryWriter. This is similar to the "add_animated_gif"
after inserting a channel dimension of 1.
Args:
Expand Down
18 changes: 16 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,19 @@ tag_prefix =
parentdir_prefix =

[mypy]
#mypy does not currently pass for monai, so disable with ignore_errors
ignore_errors = True
# do not follow imports (except for ones found in typeshed)
follow_imports=normal

# suppress errors about unsatisfied imports
ignore_missing_imports=False

# allow returning Any as a consequence of the options above
warn_return_any=True

# ensure all execution paths are returning
warn_no_return=True

# lint-style cleanliness for typing needs to be disabled; returns more errors
# than the full run.
warn_redundant_casts=True
warn_unused_ignores=True

0 comments on commit c88c567

Please sign in to comment.