compas
compas copied to clipboard
Color Error when the inputs are partly `int`
Describe the bug As titled.
To Reproduce
from compas.colors import Color
color = Color(0.0,0.0,0)
print(Color.coerce(color))
File "\compas\src\compas\colors\color.py", line 585, in coerce
raise ColorError
compas.colors.color.ColorError
@tomvanmele the current implementation coerces str
int
and float
as an argument.
this screams for a refactor with typing.overload
which was introduced in py 3.5.
implementing type specific versions of the function is much cleaner IMO.
this could be a nice segue to introduce overload
that would indeed be very nice, but unfortunately, COMPAS 2.x still has to maintain compatibility with IronPython. once we start COMPAS 3 (which will be soon), we can start using this kind of mechanism...
Terrific, could you pls label it as compas_3
as a reminder to self?
sure done