Title: AttributeError with abstract property setter and "# type: ignore" · Issue #3491 · python/mypy · GitHub
Open Graph Title: AttributeError with abstract property setter and "# type: ignore" · Issue #3491 · python/mypy
X Title: AttributeError with abstract property setter and "# type: ignore" · Issue #3491 · python/mypy
Description: I noticed the following change in behavior after upgrading to 0.511 from 0.501. Using the following minimal example $ cat abstractproperty.py |nl -b a 1 from abc import ABC 2 from abc import abstractmethod 3 from typing import List 4 5 6...
Open Graph Description: I noticed the following change in behavior after upgrading to 0.511 from 0.501. Using the following minimal example $ cat abstractproperty.py |nl -b a 1 from abc import ABC 2 from abc import abstra...
X Description: I noticed the following change in behavior after upgrading to 0.511 from 0.501. Using the following minimal example $ cat abstractproperty.py |nl -b a 1 from abc import ABC 2 from abc import abstra...
Opengraph URL: https://github.com/python/mypy/issues/3491
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AttributeError with abstract property setter and \"# type: ignore\"","articleBody":"I noticed the following change in behavior after upgrading to `0.511` from `0.501`.\r\n\r\nUsing the following minimal example\r\n```\r\n$ cat abstractproperty.py |nl -b a\r\n 1\tfrom abc import ABC\r\n 2\tfrom abc import abstractmethod\r\n 3\tfrom typing import List\r\n 4\r\n 5\r\n 6\tclass Test(ABC):\r\n 7\r\n 8\t @property\r\n 9\t def foo(self) -> List:\r\n 10\t \"\"\"Getter\"\"\"\r\n 11\r\n 12\t @foo.setter # type: ignore\r\n 13\t @abstractmethod\r\n 14\t def foo(self, value: List) -> None:\r\n 15\t \"\"\"Setter\"\"\"\r\n```\r\nthe new version of mypy gives the following error\r\n```$ mypy abstractproperty.py \r\nabstractproperty.py:14: error: Function is missing a type annotation for one or more arguments\r\n```\r\nWhile the error itself is a bit unclear in terms of what exactly is missing the type annotation, attempting to ignore line 14 with a `# type: ignore` comment \r\n```python\r\nfrom abc import ABC\r\nfrom abc import abstractmethod\r\nfrom typing import List\r\n\r\n\r\nclass Test(ABC):\r\n\r\n @property\r\n def foo(self) -> List:\r\n \"\"\"Getter\"\"\"\r\n\r\n @foo.setter # type: ignore\r\n @abstractmethod\r\n def foo(self, value: List) -> None: # type: ignore\r\n \"\"\"Setter\"\"\"\r\n```\r\nresults in an `AttributeError`\r\n```\r\nTraceback (most recent call last):\r\n File \".../bin/mypy\", line 6, in \u003cmodule>\r\n main(__file__)\r\n File \".../lib/python3.5/site-packages/mypy/main.py\", line 46, in main\r\n res = type_check_only(sources, bin_dir, options)\r\n File \".../lib/python3.5/site-packages/mypy/main.py\", line 93, in type_check_only\r\n options=options)\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 188, in build\r\n graph = dispatch(sources, manager)\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 1595, in dispatch\r\n process_graph(graph, manager)\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 1838, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 1946, in process_stale_scc\r\n graph[id].write_cache()\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 1576, in write_cache\r\n self.manager)\r\n File \".../lib/python3.5/site-packages/mypy/build.py\", line 875, in write_cache\r\n data = tree.serialize()\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 284, in serialize\r\n 'names': self.names.serialize(self._fullname),\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 2377, in serialize\r\n data[key] = value.serialize(fullname, key)\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 2325, in serialize\r\n data['node'] = self.node.serialize()\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 2176, in serialize\r\n 'names': self.names.serialize(self.fullname()),\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 2377, in serialize\r\n data[key] = value.serialize(fullname, key)\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 2325, in serialize\r\n data['node'] = self.node.serialize()\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 414, in serialize\r\n 'items': [i.serialize() for i in self.items],\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 414, in \u003clistcomp>\r\n 'items': [i.serialize() for i in self.items],\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 636, in serialize\r\n 'func': self.func.serialize(),\r\n File \".../lib/python3.5/site-packages/mypy/nodes.py\", line 579, in serialize\r\n 'type': None if self.type is None else self.type.serialize(),\r\n File \".../lib/python3.5/site-packages/mypy/types.py\", line 766, in serialize\r\n 'fallback': self.fallback.serialize(),\r\nAttributeError: 'NoneType' object has no attribute 'serialize'\r\n```\r\nMy `mypy.ini` has the following\r\n```ini\r\n[mypy]\r\ndisallow_subclassing_any = false\r\ndisallow_untyped_defs = true\r\nfollow_imports = skip\r\nignore_missing_imports = true\r\nincremental = false\r\nshow_column_numbers = true\r\nstrict_optional = true\r\nwarn_no_return = false\r\nwarn_redundant_casts = true\r\nwarn_unused_ignores = true\r\n```","author":{"url":"https://github.com/dokai","@type":"Person","name":"dokai"},"datePublished":"2017-06-01T21:24:31Z","url":"https://github.com/python/mypy/issues/3491"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:56352ecc-655b-ee8e-8e65-1abe11b18268 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBB4:36D598:6156:8250:6B00193C |
| html-safe-nonce | aefbfa47a2fd829ef545eb40fec7910cc6c559fe57269cacba3f80f7c14de69d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkI0OjM2RDU5ODo2MTU2OjgyNTA6NkIwMDE5M0MiLCJ2aXNpdG9yX2lkIjoiNzY5MDk2NjAyMjg0MDM5MTk5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c12ed1021327e953aa6af927b1a9d9fdeac7544c968dc66b3397c9568ddfd321 |
| hovercard-subject-tag | issue:233015019 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/3491/issue_layout |
| twitter:image | https://opengraph.githubassets.com/285cfe6f9c9d8b2836e4bc9f4df3d4550c5dd1d4725c88785bfc324d38ce03ad/python/mypy/issues/3491 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/285cfe6f9c9d8b2836e4bc9f4df3d4550c5dd1d4725c88785bfc324d38ce03ad/python/mypy/issues/3491 |
| og:image:alt | I noticed the following change in behavior after upgrading to 0.511 from 0.501. Using the following minimal example $ cat abstractproperty.py |nl -b a 1 from abc import ABC 2 from abc import abstra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dokai |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width