Depending on what you want to achieve with assert here, [it might not do the job correctly](http://blog.nanl.de/2009/06/asserts-in-python-may-not-work-as-expected/). Maybe raising an exception would do the job better, or maybe just not checking at all as python is dynamically typed and we should expect the API to be respected (afterall you did state the type of `keymsg` in the docstring).