Skip to content

Commit d0addc6

Browse files
committed
fix: type annotation in test helper
1 parent bc22f40 commit d0addc6

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

test/test_solvers.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
@author: sid
66
"""
77

8+
import contextlib
89
from pathlib import Path
910
from unittest.mock import MagicMock
1011

1112
import numpy as np
1213
import pytest
1314
from test_io import model # noqa: F401
1415

16+
with contextlib.suppress(ModuleNotFoundError):
17+
import mosek
18+
1519
from linopy import GREATER_EQUAL, Model, solvers
1620
from linopy.constants import Result, Solution, Status
1721
from linopy.constraints import CSRConstraint
@@ -361,7 +365,9 @@ def test_knitro_solver_no_log(tmp_path: Path) -> None:
361365
@pytest.mark.skipif(
362366
"gurobi" not in set(solvers.licensed_solvers), reason="Gurobi is not installed"
363367
)
364-
def test_gurobi_environment_with_dict(model: Model, tmp_path: Path) -> None: # noqa: F811
368+
def test_gurobi_environment_with_dict(
369+
model: Model, tmp_path: Path
370+
) -> None: # noqa: F811
365371
gurobi = solvers.Gurobi()
366372

367373
mps_file = tmp_path / "problem.mps"
@@ -387,7 +393,9 @@ def test_gurobi_environment_with_dict(model: Model, tmp_path: Path) -> None: #
387393
@pytest.mark.skipif(
388394
"gurobi" not in set(solvers.licensed_solvers), reason="Gurobi is not installed"
389395
)
390-
def test_gurobi_environment_with_gurobi_env(model: Model, tmp_path: Path) -> None: # noqa: F811
396+
def test_gurobi_environment_with_gurobi_env(
397+
model: Model, tmp_path: Path
398+
) -> None: # noqa: F811
391399
import gurobipy as gp
392400

393401
gurobi = solvers.Gurobi()
@@ -471,7 +479,10 @@ def test_xpress_gpu_feature_reflects_installed_version() -> None:
471479

472480

473481
def _make_mosek_task_mock(
474-
*, bas_solsta=None, itr_solsta=None, itg_solsta=None
482+
*,
483+
bas_solsta: "mosek.solsta | None" = None,
484+
itr_solsta: "mosek.solsta | None" = None,
485+
itg_solsta: "mosek.solsta | None" = None,
475486
) -> MagicMock:
476487
"""Build a ``mosek.Task`` mock with controlled per-soltype statuses."""
477488
mosek = pytest.importorskip("mosek", reason="Mosek is not installed")

0 commit comments

Comments
 (0)