coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
530 stars 92 forks source link

Fix for `TypeError: can only concatenate str (not "type") to str` #288

Closed Markus28 closed 2 years ago

Markus28 commented 2 years ago

An unexpected exception is encountered in the code below

>>> import mip
>>> m = mip.Model()
>>> m.remove(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/markus/OpenSourceDev/python-mip/mip/model.py", line 1429, in remove
    "Cannot handle removal of object of type "
TypeError: can only concatenate str (not "type") to str

We would want it to throw TypeError: Cannot handle removal of object of type <class 'NoneType'> from model but while the error message is assembled, a different exception is encountered because you are trying to concatenate a string to a type.

Not a big issue but it's a quick fix :)

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.