diff --git a/requirements/typing.txt b/requirements/typing.txt index 44eb019ced1..aa882423cb2 100644 --- a/requirements/typing.txt +++ b/requirements/typing.txt @@ -1,4 +1,4 @@ -mypy ==1.17.1 +mypy ==1.18.2 torch ==2.8.0 types-PyYAML diff --git a/src/torchmetrics/functional/image/ssim.py b/src/torchmetrics/functional/image/ssim.py index ccaafe66065..72e1cdee684 100644 --- a/src/torchmetrics/functional/image/ssim.py +++ b/src/torchmetrics/functional/image/ssim.py @@ -111,14 +111,14 @@ def _ssim_update( raise ValueError(f"Expected `sigma` to have positive number. Got {sigma}.") if data_range is None: - data_range = max(preds.max() - preds.min(), target.max() - target.min()) # type: ignore[call-overload] + data_range = max(preds.max() - preds.min(), target.max() - target.min()).item() elif isinstance(data_range, tuple): preds = torch.clamp(preds, min=data_range[0], max=data_range[1]) target = torch.clamp(target, min=data_range[0], max=data_range[1]) data_range = data_range[1] - data_range[0] - c1 = pow(k1 * data_range, 2) # type: ignore[operator] - c2 = pow(k2 * data_range, 2) # type: ignore[operator] + c1 = pow(k1 * data_range, 2) + c2 = pow(k2 * data_range, 2) device = preds.device channel = preds.size(1) diff --git a/src/torchmetrics/functional/text/squad.py b/src/torchmetrics/functional/text/squad.py index c52f0860e14..6d4cfd5985d 100644 --- a/src/torchmetrics/functional/text/squad.py +++ b/src/torchmetrics/functional/text/squad.py @@ -87,7 +87,7 @@ def _metric_max_over_ground_truths( metric_fn: Callable[[str, str], Tensor], prediction: str, ground_truths: list[str] ) -> Tensor: """Calculate maximum score for a predicted answer with all reference answers.""" - return max(metric_fn(prediction, truth) for truth in ground_truths) # type: ignore[type-var] + return max(metric_fn(prediction, truth) for truth in ground_truths) def _squad_input_check(