{"action":"created","issue":{"url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/57","repository_url":"https://api.github.com/repos/mrocklin/multipledispatch","labels_url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/57/comments","events_url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/57/events","html_url":"https://github.com/mrocklin/multipledispatch/issues/57","id":168684258,"number":57,"title":"Add support for dispatching to descriptors","user":{"login":"justanr","id":4221605,"avatar_url":"https://avatars.githubusercontent.com/u/4221605?v=3","gravatar_id":"","url":"https://api.github.com/users/justanr","html_url":"https://github.com/justanr","followers_url":"https://api.github.com/users/justanr/followers","following_url":"https://api.github.com/users/justanr/following{/other_user}","gists_url":"https://api.github.com/users/justanr/gists{/gist_id}","starred_url":"https://api.github.com/users/justanr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justanr/subscriptions","organizations_url":"https://api.github.com/users/justanr/orgs","repos_url":"https://api.github.com/users/justanr/repos","events_url":"https://api.github.com/users/justanr/events{/privacy}","received_events_url":"https://api.github.com/users/justanr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-01T16:13:59Z","updated_at":"2016-08-01T17:07:43Z","closed_at":null,"body":"Consider this example:\r\n\r\n```python\r\nfrom multipledispatch import dispatch\r\n\r\nclass Frob(object):\r\n    @dispatch(int)\r\n    @classmethod\r\n    def bar(cls, things):\r\n        ...\r\n```\r\n\r\nWill fail with `AttributeError: 'classmethod' object has no attribute '__name__'`, similarly with `staticmethod` and any other descriptor that doesn't proxy access to `__name__` (`property` aside)\r\n\r\nThere's a few ways to address this issue:\r\n\r\n1. The simple and easy way: Simply type check for classmethod and staticmethod. There's nothing wrong with this, unless someone uses their own descriptors (say a caching/memoizing descriptor). In which case, they're out of luck for using multiple dispatch with it.\r\n\r\n2. [The extendable but slightly questionable way](https://github.com/justanr/objtoolz/blob/68aee9a932f8bbf1b120a5da200368feec5258c5/objtoolz/descriptors/undescriptor.py) -- this works, as I implemented [`functools.singledispatch`](https://github.com/justanr/objtoolz/blob/68aee9a932f8bbf1b120a5da200368feec5258c5/objtoolz/descriptors/singledispatch.py) as a descriptor using this method however, it chokes on `staticmethod` in Python 2.7 (due to the bound/unbound distinction there).\r\n\r\n3. The middleground where a registry of allowed descriptors is kept.  **Pros:** Check just becomes `isinstance(method, one_these_descriptor_types)` and it won't choke on unraveling staticmethod. **Cons:** Global state or passing a registry to dispatch and it's subordinates."},"comment":{"url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/comments/236643146","html_url":"https://github.com/mrocklin/multipledispatch/issues/57#issuecomment-236643146","issue_url":"https://api.github.com/repos/mrocklin/multipledispatch/issues/57","id":236643146,"user":{"login":"mrocklin","id":306380,"avatar_url":"https://avatars.githubusercontent.com/u/306380?v=3","gravatar_id":"","url":"https://api.github.com/users/mrocklin","html_url":"https://github.com/mrocklin","followers_url":"https://api.github.com/users/mrocklin/followers","following_url":"https://api.github.com/users/mrocklin/following{/other_user}","gists_url":"https://api.github.com/users/mrocklin/gists{/gist_id}","starred_url":"https://api.github.com/users/mrocklin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrocklin/subscriptions","organizations_url":"https://api.github.com/users/mrocklin/orgs","repos_url":"https://api.github.com/users/mrocklin/repos","events_url":"https://api.github.com/users/mrocklin/events{/privacy}","received_events_url":"https://api.github.com/users/mrocklin/received_events","type":"User","site_admin":false},"created_at":"2016-08-01T17:07:43Z","updated_at":"2016-08-01T17:07:43Z","body":"The simple and easy way would also be fine by me by the way.  I don't have strong opinions here as long as it's easy to maintain, doesn't hurt performance, and gets the immediate job done.  It's entirely possible that a long chain of if-statements satisfies these requirements."}}
{"actor":{"display_login":"mrocklin"}}