From 7874b4469ea8d2651c5b9e22c86cbb5a9aa98a66 Mon Sep 17 00:00:00 2001 From: Jason Chow Date: Fri, 20 Dec 2024 13:51:54 -0800 Subject: [PATCH] Fix latest mypy errors and pin mypy version (#492) Summary: Pull Request resolved: https://github.com/facebookresearch/aepsych/pull/492 New mypy errors due to mypy update. We update to latest mypy version and now pin so we don't get more surprises. Note that the ignore in dim_grid is necessary as that is a perfectly valid use of slice (with imaginary numbers for the step value) but mypy seems to not understand that usage in numpy. Reviewed By: crasanders Differential Revision: D67537899 fbshipit-source-id: 312f7bdd54d8f1534e653e219cfde728a88d11ef --- aepsych/transforms/ops/fixed.py | 3 +++ aepsych/utils.py | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aepsych/transforms/ops/fixed.py b/aepsych/transforms/ops/fixed.py index 67d5d91bc..feb77613e 100644 --- a/aepsych/transforms/ops/fixed.py +++ b/aepsych/transforms/ops/fixed.py @@ -126,6 +126,9 @@ def get_config_options( if "values" not in options: value = config[name].get("value") + if value is None: + raise ValueError(f"Value option not found in {name} section.") + try: options["values"] = [float(value)] except ValueError: diff --git a/aepsych/utils.py b/aepsych/utils.py index c1474e711..7383a8a7a 100644 --- a/aepsych/utils.py +++ b/aepsych/utils.py @@ -84,7 +84,7 @@ def dim_grid( if i in slice_dims.keys(): mesh_vals.append(slice(slice_dims[i] - 1e-10, slice_dims[i] + 1e-10, 1)) else: - mesh_vals.append(slice(lower[i].item(), upper[i].item(), gridsize * 1j)) + mesh_vals.append(slice(lower[i].item(), upper[i].item(), gridsize * 1j)) # type: ignore return torch.Tensor(np.mgrid[mesh_vals].reshape(dim, -1).T) diff --git a/setup.py b/setup.py index ad19d9ed7..941405fde 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ "flake8", "black", "sqlalchemy-stubs", # for mypy stubs - "mypy", + "mypy==1.14.0", "parameterized", "scikit-learn", # used in unit tests ]