I have a library that can take either a class function or a normal function with certain signatures. A class normally looks like this:
class MyObject(object):
def __init__(self, request):
self.request = request
def run(self):
return 'OK'
and the function format is this:
def my_func(request):
retrn 'OK'
The usage of this is:
add_runner(MyObject, attr='run')
add_runner(my_func)
but sometimes people utilize this wrong and pass the class function to my library:
add_runner(MyObject.run)
I have detected this in Python 2.x as an unbound method and raise an error to alert them that they are using my API wrong but in Python 3.x I can't find any way to actually detect they are doing this wrong. What am I missing?