{"action":"opened","issue":{"url":"https://api.github.com/repos/python/mypy/issues/1956","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/1956/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/1956/comments","events_url":"https://api.github.com/repos/python/mypy/issues/1956/events","html_url":"https://github.com/python/mypy/issues/1956","id":168233245,"number":1956,"title":"Error in subclass of generic base at None","user":{"login":"gnprice","id":28173,"avatar_url":"https://avatars.githubusercontent.com/u/28173?v=3","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python/mypy/labels/affects/strict-optional","name":"affects/strict-optional","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-29T01:39:41Z","updated_at":"2016-07-29T01:39:41Z","closed_at":null,"body":"Under `--strict-optional`, when inheriting from a generic base class applied to None, method implementations on the subclass can produce spurious errors like so:\r\n\r\n```\r\n$ cat /tmp/foo.py\r\nfrom typing import Generic, TypeVar\r\n\r\nT = TypeVar('T')\r\n\r\nclass Base(Generic[T]):\r\n  def f(self) -> T:\r\n    pass\r\n\r\nclass SubNone(Base[None]):\r\n  def f(self) -> None:\r\n    pass\r\n\r\nclass SubInt(Base[int]):\r\n  def f(self) -> int:\r\n    return 1\r\n\r\n$ mypy /tmp/foo.py --strict-optional\r\n/tmp/foo.py: note: In class \"SubNone\":\r\n/tmp/foo.py:10: error: Return type of \"f\" incompatible with supertype \"Base\"\r\n```\r\n\r\nNote there's no error when the same thing is done with `int` instead of `None`. There's also no error without `--strict-optional`.\r\n\r\nThis issue causes about 109 error messages when type-checking mypy itself under `--strict-optional`, in various subclasses of `NodeVisitor[None]` and `TypeVisitor[None]`.\r\n\r\nI haven't tried hard to reduce this repro -- it's possible that some of the elements of it are unnecessary.\r\n"}}
{"actor":{"display_login":"gnprice"}}