{"action":"created","issue":{"url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/107","repository_url":"https://api.github.com/repos/grantjenks/python-sortedcontainers","labels_url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/107/comments","events_url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/107/events","html_url":"https://github.com/grantjenks/python-sortedcontainers/pull/107","id":385741896,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0NjQxODg2","number":107,"title":"Add type annotations to sortedcontainers","user":{"login":"althonos","id":8660647,"node_id":"MDQ6VXNlcjg2NjA2NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/8660647?v=4","gravatar_id":"","url":"https://api.github.com/users/althonos","html_url":"https://github.com/althonos","followers_url":"https://api.github.com/users/althonos/followers","following_url":"https://api.github.com/users/althonos/following{/other_user}","gists_url":"https://api.github.com/users/althonos/gists{/gist_id}","starred_url":"https://api.github.com/users/althonos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/althonos/subscriptions","organizations_url":"https://api.github.com/users/althonos/orgs","repos_url":"https://api.github.com/users/althonos/repos","events_url":"https://api.github.com/users/althonos/events{/privacy}","received_events_url":"https://api.github.com/users/althonos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-29T13:41:51Z","updated_at":"2018-12-07T20:09:24Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/pulls/107","html_url":"https://github.com/grantjenks/python-sortedcontainers/pull/107","diff_url":"https://github.com/grantjenks/python-sortedcontainers/pull/107.diff","patch_url":"https://github.com/grantjenks/python-sortedcontainers/pull/107.patch"},"body":"Hi @grantjenks,\r\n\r\nthis PR adds type annotations to the `sortedcontainers` package. They should be consistent with their `list`, `set` and `dict` annotations from the `typeshed` annotations. All collections are invariant generics.\r\n\r\nHere are the current quirks:\r\n\r\n* `__new__` annotations are not supported, so `mypy` does not understand that creating a `SortedList` with a key argument returns a `SortedKeyList` instance (this is a `mypy` bug, see python/mypy#3307)\r\n* `SortedItemsView` raises an error because of supposedly incompatible base classes (this is a `mypy` bug, see python/mypy#5973)\r\n* Until `typing` exposes `Protocol`s, it is not really possible to set the return type of `key` functions. This means that the acceptable type for a key is `Callable[[T], Any]`. In particular, this also means that `bisect_key_left` and `bisect_key_right` accept `Any`. The other way around would be to make `SortedList` a generic over both `T` and `K` where `K` is the key type, but that would possibly be a hindrance to end users.\r\n* `SortedKeyList.__contains__(value)` should accept anything (as any `Sequence`), but since the value is passed to `self._key`, the value should be of type `T` for the code never to fail. The choices are: either only accept `T`, typecheck the value in the code, or return False on any `TypeError` raised by the key. None of them are really satisfactory IMO."},"comment":{"url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/comments/445350975","html_url":"https://github.com/grantjenks/python-sortedcontainers/pull/107#issuecomment-445350975","issue_url":"https://api.github.com/repos/grantjenks/python-sortedcontainers/issues/107","id":445350975,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTM1MDk3NQ==","user":{"login":"althonos","id":8660647,"node_id":"MDQ6VXNlcjg2NjA2NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/8660647?v=4","gravatar_id":"","url":"https://api.github.com/users/althonos","html_url":"https://github.com/althonos","followers_url":"https://api.github.com/users/althonos/followers","following_url":"https://api.github.com/users/althonos/following{/other_user}","gists_url":"https://api.github.com/users/althonos/gists{/gist_id}","starred_url":"https://api.github.com/users/althonos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/althonos/subscriptions","organizations_url":"https://api.github.com/users/althonos/orgs","repos_url":"https://api.github.com/users/althonos/repos","events_url":"https://api.github.com/users/althonos/events{/privacy}","received_events_url":"https://api.github.com/users/althonos/received_events","type":"User","site_admin":false},"created_at":"2018-12-07T20:09:24Z","updated_at":"2018-12-07T20:09:24Z","author_association":"NONE","body":"@bryanforbes : thanks for reviewing my code ! I let so much slip through it's mostly thanks to you this PR became high-standard enough :wink: "}}
{"actor":{"display_login":"althonos"}}