{"action":"created","issue":{"url":"https://api.github.com/repos/python/typing/issues/580","repository_url":"https://api.github.com/repos/python/typing","labels_url":"https://api.github.com/repos/python/typing/issues/580/labels{/name}","comments_url":"https://api.github.com/repos/python/typing/issues/580/comments","events_url":"https://api.github.com/repos/python/typing/issues/580/events","html_url":"https://github.com/python/typing/pull/580","id":354109911,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwOTYwNDY4","number":580,"title":"Fix instance/subclass checks of functions against runtime protocols.","user":{"login":"erikwright","id":187063,"node_id":"MDQ6VXNlcjE4NzA2Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/187063?v=4","gravatar_id":"","url":"https://api.github.com/users/erikwright","html_url":"https://github.com/erikwright","followers_url":"https://api.github.com/users/erikwright/followers","following_url":"https://api.github.com/users/erikwright/following{/other_user}","gists_url":"https://api.github.com/users/erikwright/gists{/gist_id}","starred_url":"https://api.github.com/users/erikwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikwright/subscriptions","organizations_url":"https://api.github.com/users/erikwright/orgs","repos_url":"https://api.github.com/users/erikwright/repos","events_url":"https://api.github.com/users/erikwright/events{/privacy}","received_events_url":"https://api.github.com/users/erikwright/received_events","type":"User","site_admin":false},"labels":[{"id":465632570,"node_id":"MDU6TGFiZWw0NjU2MzI1NzA=","url":"https://api.github.com/repos/python/typing/labels/CLA%20not%20signed","name":"CLA not signed","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-26T16:55:26Z","updated_at":"2018-08-26T16:55:28Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/python/typing/pulls/580","html_url":"https://github.com/python/typing/pull/580","diff_url":"https://github.com/python/typing/pull/580.diff","patch_url":"https://github.com/python/typing/pull/580.patch"},"body":"Fixes #579 .\r\n\r\nWhen performing an `issubclass` check of a type against a protocol, the `__annotations__` member of the type is accessed and assumed to be iterable. `__annotations__` is a descriptor in the case of `types.FunctionType`, so while it is iterable when accessed on a function instance it is not iterable when accessed on the type of a function. This causes the `issubclass` check to fail with an exception.\r\n\r\nIn some cases (AFAICT, non-data protocols), an `isinstance` check of an object will use, internally, a subclass check of the object's type. As a result, `isinstance` will also fail with an exception in these conditions.\r\n\r\nThe above only seemed to occur in Python 3.\r\n\r\nThis PR fixes the issue in the Python 3 implementation while adding test coverage for both Python 2 and 3 that ensures that functions (and `types.FunctionType`) can be correctly compared both against protocols that they legitimately implement as well as those that they do not implement."},"comment":{"url":"https://api.github.com/repos/python/typing/issues/comments/416052652","html_url":"https://github.com/python/typing/pull/580#issuecomment-416052652","issue_url":"https://api.github.com/repos/python/typing/issues/580","id":416052652,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjA1MjY1Mg==","user":{"login":"the-knights-who-say-ni","id":18121554,"node_id":"MDQ6VXNlcjE4MTIxNTU0","avatar_url":"https://avatars0.githubusercontent.com/u/18121554?v=4","gravatar_id":"","url":"https://api.github.com/users/the-knights-who-say-ni","html_url":"https://github.com/the-knights-who-say-ni","followers_url":"https://api.github.com/users/the-knights-who-say-ni/followers","following_url":"https://api.github.com/users/the-knights-who-say-ni/following{/other_user}","gists_url":"https://api.github.com/users/the-knights-who-say-ni/gists{/gist_id}","starred_url":"https://api.github.com/users/the-knights-who-say-ni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-knights-who-say-ni/subscriptions","organizations_url":"https://api.github.com/users/the-knights-who-say-ni/orgs","repos_url":"https://api.github.com/users/the-knights-who-say-ni/repos","events_url":"https://api.github.com/users/the-knights-who-say-ni/events{/privacy}","received_events_url":"https://api.github.com/users/the-knights-who-say-ni/received_events","type":"User","site_admin":false},"created_at":"2018-08-26T16:55:28Z","updated_at":"2018-08-26T16:55:28Z","author_association":"NONE","body":"Hello, and thanks for your contribution!\n\nI'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the [PSF contributor agreement](https://www.python.org/psf/contrib/contrib-form/) (CLA).\n\nUnfortunately we couldn't find an account corresponding to your GitHub username on [bugs.python.org](https://bugs.python.org/) (b.p.o) to verify you have signed the CLA (this might be simply due to a missing \"GitHub Name\" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow [the steps outlined in the CPython devguide](https://devguide.python.org/pullrequest/#licensing) to rectify this issue.\n\n\nYou can [check yourself](https://check-python-cla.herokuapp.com/) to see if the CLA has been received.\n\nThanks again for your contribution, we look forward to reviewing it!\n"}}
{"actor":{"display_login":"the-knights-who-say-ni"}}