Discussion was done at https://gitter.im/encode/community. Bug was confirmed by @Kludex.
Description
methods don't get detected on is_function, then we assume that <object>.__class__.__name__ will give the right name (my_method on the example below) for it, but it actually gets the "method" name, which is wrong.
Unexpected behaviour seem to originate from: https://github.com/encode/starlette/blob/e086fc2da361767b532cf690e5203619bbae98aa/starlette/routing.py#L87
Minimal example
from starlette.responses import JSONResponse
from starlette.routing import Route
async def my_function(request):
return JSONResponse({'endpoint_type': 'function'})
class MyClass:
def __call__(self, request):
return JSONResponse({'endpoint_type': 'class'})
class MySpecialEndpointObject:
async def my_method(self, request):
return JSONResponse({'endpoint_type': 'method'})
endpoint_obj = MySpecialEndpointObject()
function_route = Route('/functionEndpoint', my_function)
class_route = Route('/classEndpoint', MyClass())
method_route = Route('/methodEndpoint', endpoint_obj.my_method)
assert function_route.name == "my_function"
assert class_route.name == "MyClass"
assert method_route.name == "my_method" # AssertionError
Actual behavior
Value of method_route.name is "method".
Expected behavior
Value of method_route.name is "my_method".
It could also be "MySpecialEndpointObject_my_method". Reason here is to prevent ambiguity.
Discussion was done at https://gitter.im/encode/community. Bug was confirmed by @Kludex.
Description
methods don't get detected on
is_function, then we assume that<object>.__class__.__name__will give the right name (my_method on the example below) for it, but it actually gets the "method" name, which is wrong.Unexpected behaviour seem to originate from: https://github.com/encode/starlette/blob/e086fc2da361767b532cf690e5203619bbae98aa/starlette/routing.py#L87
Minimal example
Actual behavior
Value of
method_route.nameis"method".Expected behavior
Value of
method_route.nameis"my_method".It could also be
"MySpecialEndpointObject_my_method". Reason here is to prevent ambiguity.