{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/5975","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/5975/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/5975/comments","events_url":"https://api.github.com/repos/python/mypy/issues/5975/events","html_url":"https://github.com/python/mypy/pull/5975","id":385955520,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0ODA5MTU1","number":5975,"title":"Support for overloaded functions in stubgenc generated by pybind11","user":{"login":"wiktorn","id":3180307,"node_id":"MDQ6VXNlcjMxODAzMDc=","avatar_url":"https://avatars1.githubusercontent.com/u/3180307?v=4","gravatar_id":"","url":"https://api.github.com/users/wiktorn","html_url":"https://github.com/wiktorn","followers_url":"https://api.github.com/users/wiktorn/followers","following_url":"https://api.github.com/users/wiktorn/following{/other_user}","gists_url":"https://api.github.com/users/wiktorn/gists{/gist_id}","starred_url":"https://api.github.com/users/wiktorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiktorn/subscriptions","organizations_url":"https://api.github.com/users/wiktorn/orgs","repos_url":"https://api.github.com/users/wiktorn/repos","events_url":"https://api.github.com/users/wiktorn/events{/privacy}","received_events_url":"https://api.github.com/users/wiktorn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-29T22:31:30Z","updated_at":"2018-12-01T00:49:12Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/python/mypy/pulls/5975","html_url":"https://github.com/python/mypy/pull/5975","diff_url":"https://github.com/python/mypy/pull/5975.diff","patch_url":"https://github.com/python/mypy/pull/5975.patch"},"body":"For overloaded methods pybind generates following docstring:\r\n> ```\r\n> __init__(*args, **kwargs)\r\n> Overloaded function.\r\n> \r\n> 1. __init__(self: TestClass, arg0: str) -> None\r\n> \r\n> 2. __init__(self: TestClass, arg0: str, arg1: str) -> None\r\n> ```\r\nFor such docstrings stubgenc will produce following stub:\r\n```\r\n@overload\r\ndef __init__(self, arg0: str) -> None: ...\r\n@overload\r\ndef __init__(self, arg0: str, arg1: str) -> None: ...\r\n```\r\n\r\nThis pull request introduces:\r\n* class - TypedFunctionSig - representing signature of function/method (function name, arguments, return value)\r\n* class - TypedArgSig  - representing information about function argument (argument name, type, default value)\r\n\r\n`infer_sig_from_docstring` now returns list of `TypedFunctionSig` . List contains one object when function is not overloaded, more objects - when it's overloaded. Each object represents signature of function.\r\n\r\n`infer_arg_sig_from_docstring` is a new function that parses argument list for function in docstring. As the type information may contain commas, the code checks, if the comma is outside brackets. I tried to approach that with regex and failed, also tried to use `ast` module, but its not straightforward to move from ast form back to source code form that's why I settled with naive approach, as this is not performance critical path. Tests for edge cases included in `test_infer_sig_from_docstring`"},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/443382894","html_url":"https://github.com/python/mypy/pull/5975#issuecomment-443382894","issue_url":"https://api.github.com/repos/python/mypy/issues/5975","id":443382894,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzM4Mjg5NA==","user":{"login":"gvanrossum","id":2894642,"node_id":"MDQ6VXNlcjI4OTQ2NDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2894642?v=4","gravatar_id":"","url":"https://api.github.com/users/gvanrossum","html_url":"https://github.com/gvanrossum","followers_url":"https://api.github.com/users/gvanrossum/followers","following_url":"https://api.github.com/users/gvanrossum/following{/other_user}","gists_url":"https://api.github.com/users/gvanrossum/gists{/gist_id}","starred_url":"https://api.github.com/users/gvanrossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvanrossum/subscriptions","organizations_url":"https://api.github.com/users/gvanrossum/orgs","repos_url":"https://api.github.com/users/gvanrossum/repos","events_url":"https://api.github.com/users/gvanrossum/events{/privacy}","received_events_url":"https://api.github.com/users/gvanrossum/received_events","type":"User","site_admin":false},"created_at":"2018-12-01T00:49:12Z","updated_at":"2018-12-01T00:49:12Z","author_association":"MEMBER","body":"> For such docstrings stubgenc will produce following stub:\r\n\r\nI presume you mean that stubgenc *should* produce such a stub, and this PR implements that behavior? (We prefer our commit messages to describe the change rather than the new state of affairs.)\r\n\r\nI will try to review now, but I think this has missed the train for the upcoming 0.650 release (see #5960)."}}
{"actor":{"display_login":"gvanrossum"}}