def convert_params(exception=ValueError, error=400):
 request = cherrypy.serving.request
 types = request.handler.callable.__annotations__
 with cherrypy.HTTPError.handle(exception, error):
  for key in set(types).intersection(request.params):
   request.params[key] = types[key](request.params[key])

def convert_params ( exception = ValueError , error = 400 ) : request = cherrypy . serving . request types = request . handler . callable . __annotations__ with cherrypy . HTTPError . handle ( exception , error ) : for key in set ( types ) . intersection ( request . params ) : request . params [ key ] = types [ key ] ( request . params [ key ] )
convert request params based on function annotations .