Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when a method is passed as an endpoint #126

Closed
taoufik07 opened this issue Oct 22, 2018 · 2 comments
Closed

Error when a method is passed as an endpoint #126

taoufik07 opened this issue Oct 22, 2018 · 2 comments

Comments

@taoufik07
Copy link
Collaborator

taoufik07 commented Oct 22, 2018

When a method is passed as an endpoint and we try to add is_routed to it, an attribute error is raised and it's passed it silently, So the route.is_function fails and that's what caused schemas to fail since the endpoint is a mehtod API.schema_response.

UPDATE

One of the solutions :

@property
def is_function(self):
    # We can also remove is_routed ?
    routed = hasattr(self.endpoint, "is_routed") or callable(self.endpoint)
    code = hasattr(self.endpoint, "__code__")
    kwdefaults = hasattr(self.endpoint, "__kwdefaults__")
    return all((routed, code, kwdefaults))

or :

try:
    if callable(endpoint):
        endpoint.__dict__["is_routed"] = True
except TypeError:
    pass

@kennethreitz What solution you prefer ?

@taoufik07
Copy link
Collaborator Author

You can now close this issue since you've merged #131

@taoufik07
Copy link
Collaborator Author

Need to be reopened since you reverted :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants