Add types to remaining files; activate mypy's disallow_untyped_defs

This commit is contained in:
2021-04-07 21:25:30 -05:00
parent f5606efb72
commit e9cd6d1715
21 changed files with 102 additions and 64 deletions

View File

@@ -36,8 +36,9 @@ class InfeasibleGurobiInstance(Instance):
return model
def get_infeasible_instance(solver):
def get_infeasible_instance(solver: Any) -> Instance:
if _is_subclass_or_instance(solver, BasePyomoSolver):
return InfeasiblePyomoInstance()
if _is_subclass_or_instance(solver, GurobiSolver):
return InfeasibleGurobiInstance()
assert False

View File

@@ -1,6 +1,9 @@
# MIPLearn: Extensible Framework for Learning-Enhanced Mixed-Integer Optimization
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
from typing import List, Any, Tuple
from miplearn.instance.base import Instance
from miplearn.problems.knapsack import KnapsackInstance, GurobiKnapsackInstance
from miplearn.solvers.gurobi import GurobiSolver
@@ -10,7 +13,7 @@ from miplearn.solvers.pyomo.base import BasePyomoSolver
from tests.solvers import _is_subclass_or_instance
def get_test_pyomo_instances():
def get_test_pyomo_instances() -> Tuple[List[Instance], List[Any]]:
instances = [
KnapsackInstance(
weights=[23.0, 26.0, 20.0, 18.0],

View File

@@ -34,8 +34,9 @@ class GurobiInstanceWithRedundancy(Instance):
return model
def get_instance_with_redundancy(solver):
def get_instance_with_redundancy(solver: Any) -> Instance:
if _is_subclass_or_instance(solver, BasePyomoSolver):
return PyomoInstanceWithRedundancy()
if _is_subclass_or_instance(solver, GurobiSolver):
return GurobiInstanceWithRedundancy()
assert False