update python typing

This commit is contained in:
Laurent Perron
2025-07-28 10:34:20 -07:00
parent 99ede3bbde
commit 87a66e6239
3 changed files with 10 additions and 7 deletions

View File

@@ -32,10 +32,11 @@ Other methods and functions listed are primarily used for developing OR-Tools,
rather than for solving specific optimization problems.
"""
from collections.abc import Callable
import math
import numbers
import typing
from typing import Callable, Optional, Union
from typing import Optional, Union
import numpy as np
import pandas as pd

View File

@@ -13,8 +13,9 @@
"""helpers methods for the cp_model_builder module on numbers."""
from collections.abc import Sequence
import numbers
from typing import Any, Sequence, Union
from typing import Any, Union
import numpy as np
import numpy.typing as npt

View File

@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from collections.abc import Callable, Mapping
import math
import sys
from typing import Any, Callable, Dict, Mapping, Union
from typing import Any, Union
from absl.testing import absltest
from absl.testing import parameterized
@@ -30,7 +31,7 @@ from ortools.linear_solver.python import model_builder as mb
from ortools.linear_solver.python import model_builder_helper as mbh
def build_dict(expr: mb.LinearExprT) -> Dict[mbh.Variable, float]:
def build_dict(expr: mb.LinearExprT) -> dict[mbh.Variable, float]:
res = {}
flat_expr = mbh.FlatExpr(expr)
for var, coeff in zip(flat_expr.vars, flat_expr.coeffs):
@@ -1858,7 +1859,7 @@ class SolverTest(parameterized.TestCase):
)
def test_solve_status(
self,
solver: Dict[str, Union[str, Mapping[str, Any], bool]],
solver: dict[str, Union[str, Mapping[str, Any], bool]],
variable_indices: pd.Index,
variable_bound: float,
solve_status: mb.SolveStatus,
@@ -1934,7 +1935,7 @@ class SolverTest(parameterized.TestCase):
)
def test_get_variable_values(
self,
solver: Dict[str, Union[str, Mapping[str, Any], bool]],
solver: dict[str, Union[str, Mapping[str, Any], bool]],
variable_indices: pd.Index,
variable_bound: float,
solve_status: mb.SolveStatus,
@@ -2012,7 +2013,7 @@ class SolverTest(parameterized.TestCase):
)
def test_get_objective_value(
self,
solver: Dict[str, Union[str, Mapping[str, Any], bool]],
solver: dict[str, Union[str, Mapping[str, Any], bool]],
variable_indices: pd.Index,
variable_bound: float,
solve_status: mb.SolveStatus,