From f15a17c5511cd739fc4685c211ec71210332ad64 Mon Sep 17 00:00:00 2001 From: mcflugen Date: Mon, 19 Oct 2026 16:49:29 -0600 Subject: [PATCH] guard generated numpy imports with TYPE_CHECKING --- noxfile.py | 2 +- pyproject.toml | 1 - src/bmipy/_template.py | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index 0e7a0f4..ef7cec7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -21,7 +21,7 @@ def test(session: nox.Session) -> None: if path is not None: pytest_args = ("--import-mode=importlib", "--pyargs", "bmipy", "tests") - session.install("coverage", "pytest", "numpy") + session.install("coverage", "pytest") session.run("coverage", "erase") session.run( diff --git a/pyproject.toml b/pyproject.toml index a24bf20..71b796d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ dynamic = [ dev = ["nox"] testing = [ "coverage", - "numpy", "pytest", ] diff --git a/src/bmipy/_template.py b/src/bmipy/_template.py index ff6d721..d5ddce0 100644 --- a/src/bmipy/_template.py +++ b/src/bmipy/_template.py @@ -41,9 +41,11 @@ def render(self, with_docstring: bool = True) -> str: from __future__ import annotations from typing import Any +from typing import TYPE_CHECKING -import numpy as np -from numpy.typing import NDArray +if TYPE_CHECKING: + import numpy as np + from numpy.typing import NDArray from bmipy.bmi import Bmi