Skip to content

Commit 140f9e6

Browse files
authored
fixed typing warnings (#842)
* fixed typing warnings * another ignore * 3.9 types
1 parent e078a45 commit 140f9e6

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

pulp/tests/test_gurobipy_env.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
from pulp import GUROBI, LpProblem, LpVariable, const
44

55
try:
6-
import gurobipy as gp # type: ignore[import-not-found]
7-
from gurobipy import GRB
6+
import gurobipy as gp # type: ignore[import-not-found, import-untyped, unused-ignore]
87
except ImportError:
9-
gp = None
8+
gp = None # type: ignore[assignment, unused-ignore]
109

1110

1211
def check_dummy_env():

pulp/tests/test_pulp.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import tempfile
99
import unittest
1010
from decimal import Decimal
11-
from typing import Union
11+
from typing import Union, Optional
1212

1313

1414
from pulp import (
@@ -28,7 +28,7 @@
2828
from pulp.utilities import makeDict
2929

3030
try:
31-
import gurobipy as gp # type: ignore[import-not-found,no-redef]
31+
import gurobipy as gp # type: ignore
3232
except ImportError:
3333
gp = None
3434

@@ -97,7 +97,7 @@ def dumpTestProblem(prob):
9797

9898
class BaseSolverTest:
9999
class PuLPTest(unittest.TestCase):
100-
solveInst = None
100+
solveInst: Optional[Type[LpSolver]] = None
101101

102102
def setUp(self):
103103
self.solver = self.solveInst(msg=False)
@@ -1833,7 +1833,7 @@ def test_decimal_815_addinplace(self):
18331833

18341834

18351835
class PULP_CBC_CMDTest(BaseSolverTest.PuLPTest):
1836-
solveInst = PULP_CBC_CMD # type: ignore[assignment]
1836+
solveInst = PULP_CBC_CMD
18371837

18381838
@staticmethod
18391839
def read_command_line_from_log_file(logPath):
@@ -2030,31 +2030,31 @@ def test_strong(self):
20302030

20312031

20322032
class CPLEX_CMDTest(BaseSolverTest.PuLPTest):
2033-
solveInst = CPLEX_CMD # type: ignore[assignment]
2033+
solveInst = CPLEX_CMD
20342034

20352035

20362036
class CPLEX_PYTest(BaseSolverTest.PuLPTest):
2037-
solveInst = CPLEX_CMD # type: ignore[assignment]
2037+
solveInst = CPLEX_CMD
20382038

20392039

20402040
class XPRESS_CMDTest(BaseSolverTest.PuLPTest):
2041-
solveInst = XPRESS_CMD # type: ignore[assignment]
2041+
solveInst = XPRESS_CMD
20422042

20432043

20442044
class XPRESS_PyTest(BaseSolverTest.PuLPTest):
2045-
solveInst = XPRESS_PY # type: ignore[assignment]
2045+
solveInst = XPRESS_PY
20462046

20472047

20482048
class COIN_CMDTest(BaseSolverTest.PuLPTest):
2049-
solveInst = COIN_CMD # type: ignore[assignment]
2049+
solveInst = COIN_CMD
20502050

20512051

20522052
class COINMP_DLLTest(BaseSolverTest.PuLPTest):
2053-
solveInst = COINMP_DLL # type: ignore[assignment]
2053+
solveInst = COINMP_DLL
20542054

20552055

20562056
class GLPK_CMDTest(BaseSolverTest.PuLPTest):
2057-
solveInst = GLPK_CMD # type: ignore[assignment]
2057+
solveInst = GLPK_CMD
20582058

20592059
def test_issue814_rounding_mip(self):
20602060
"""
@@ -2152,55 +2152,55 @@ def test_decimal_815(self):
21522152

21532153

21542154
class GUROBITest(BaseSolverTest.PuLPTest):
2155-
solveInst = GUROBI # type: ignore[assignment]
2155+
solveInst = GUROBI
21562156

21572157

21582158
class GUROBI_CMDTest(BaseSolverTest.PuLPTest):
2159-
solveInst = GUROBI_CMD # type: ignore[assignment]
2159+
solveInst = GUROBI_CMD
21602160

21612161

21622162
class PYGLPKTest(BaseSolverTest.PuLPTest):
2163-
solveInst = PYGLPK # type: ignore[assignment]
2163+
solveInst = PYGLPK
21642164

21652165

21662166
class YAPOSIBTest(BaseSolverTest.PuLPTest):
2167-
solveInst = YAPOSIB # type: ignore[assignment]
2167+
solveInst = YAPOSIB
21682168

21692169

21702170
class CHOCO_CMDTest(BaseSolverTest.PuLPTest):
2171-
solveInst = CHOCO_CMD # type: ignore[assignment]
2171+
solveInst = CHOCO_CMD
21722172

21732173

21742174
class MIPCL_CMDTest(BaseSolverTest.PuLPTest):
2175-
solveInst = MIPCL_CMD # type: ignore[assignment]
2175+
solveInst = MIPCL_CMD
21762176

21772177

21782178
class MOSEKTest(BaseSolverTest.PuLPTest):
2179-
solveInst = MOSEK # type: ignore[assignment]
2179+
solveInst = MOSEK
21802180

21812181

21822182
class SCIP_CMDTest(BaseSolverTest.PuLPTest):
2183-
solveInst = SCIP_CMD # type: ignore[assignment]
2183+
solveInst = SCIP_CMD
21842184

21852185

21862186
class FSCIP_CMDTest(BaseSolverTest.PuLPTest):
2187-
solveInst = FSCIP_CMD # type: ignore[assignment]
2187+
solveInst = FSCIP_CMD
21882188

21892189

21902190
class SCIP_PYTest(BaseSolverTest.PuLPTest):
2191-
solveInst = SCIP_PY # type: ignore[assignment]
2191+
solveInst = SCIP_PY
21922192

21932193

21942194
class HiGHS_PYTest(BaseSolverTest.PuLPTest):
2195-
solveInst = HiGHS # type: ignore[assignment]
2195+
solveInst = HiGHS
21962196

21972197

21982198
class HiGHS_CMDTest(BaseSolverTest.PuLPTest):
2199-
solveInst = HiGHS_CMD # type: ignore[assignment]
2199+
solveInst = HiGHS_CMD
22002200

22012201

22022202
class COPTTest(BaseSolverTest.PuLPTest):
2203-
solveInst = COPT # type: ignore[assignment]
2203+
solveInst = COPT
22042204

22052205

22062206
class SASTest:
@@ -2222,11 +2222,11 @@ def test_sas_with_option(self):
22222222

22232223

22242224
class SAS94Test(BaseSolverTest.PuLPTest, SASTest):
2225-
solveInst = SAS94 # type: ignore[assignment]
2225+
solveInst = SAS94
22262226

22272227

22282228
class SASCASTest(BaseSolverTest.PuLPTest, SASTest):
2229-
solveInst = SASCAS # type: ignore[assignment]
2229+
solveInst = SASCAS
22302230

22312231

22322232
# class CyLPTest(BaseSolverTest.PuLPTest):

0 commit comments

Comments
 (0)