I highly reccomend using rosidl_generator_mypy however this float accepting an int is a problem carried over from the pep 484 spec. There is currently no type hint to specify float but not int. There is lot of debate about this in the python typing scene.