Title: Run `mypy` on `cases_generator` · Issue #104504 · python/cpython · GitHub
Open Graph Title: Run `mypy` on `cases_generator` · Issue #104504 · python/cpython
X Title: Run `mypy` on `cases_generator` · Issue #104504 · python/cpython
Description: Feature or enhancement After #104421 is merged, we now have the precedent and the needed infrastructure to run mypy on things that support type annotations in Tools/ Pitch Maybe we should run it on Tools/cases_generator? It has all annot...
Open Graph Description: Feature or enhancement After #104421 is merged, we now have the precedent and the needed infrastructure to run mypy on things that support type annotations in Tools/ Pitch Maybe we should run it on...
X Description: Feature or enhancement After #104421 is merged, we now have the precedent and the needed infrastructure to run mypy on things that support type annotations in Tools/ Pitch Maybe we should run it on...
Opengraph URL: https://github.com/python/cpython/issues/104504
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Run `mypy` on `cases_generator`","articleBody":"# Feature or enhancement\r\n\r\nAfter https://github.com/python/cpython/pull/104421 is merged, we now have the precedent and the needed infrastructure to run `mypy` on things that support type annotations in `Tools/`\r\n\r\n# Pitch\r\n\r\nMaybe we should run it on `Tools/cases_generator`? It has all annotations in place, it needs very little work. Right now `mypy` finds only 24 errors.\r\n\r\nFull list:\r\n\r\n```python\r\n» mypy .\r\nparser.py:22: error: Return value expected [return-value]\r\n return\r\n ^~~~~~\r\nparser.py:142: error: Missing return statement [return]\r\n def definition(self) -\u003e InstDef | Super | Macro | Family | None:\r\n ^\r\nparser.py:168: error: Module has no attribute \"OVERRIDE\" [attr-defined]\r\n override = bool(self.expect(lx.OVERRIDE))\r\n ^~~~~~~~~~~\r\nparser.py:169: error: Module has no attribute \"REGISTER\" [attr-defined]\r\n register = bool(self.expect(lx.REGISTER))\r\n ^~~~~~~~~~~\r\nparser.py:177: error: Argument 3 to \"InstHeader\" has incompatible type \"str\";\r\nexpected \"Literal['inst', 'op', 'legacy']\" [arg-type]\r\n ... return InstHeader(override, register, kind, name, inp, outp...\r\n ^~~~\r\nparser.py:200: error: Incompatible return value type (got\r\n\"List[Union[StackEffect, CacheEffect, Node]]\", expected\r\n\"Optional[List[Union[StackEffect, CacheEffect]]]\") [return-value]\r\n return [inp] + rest\r\n ^~~~~~~~~~~~\r\nparser.py:202: error: List item 0 has incompatible type \"Node\"; expected\r\n\"Union[StackEffect, CacheEffect]\" [list-item]\r\n return [inp]\r\n ^~~\r\nparser.py:228: error: Missing return statement [return]\r\n def cache_effect(self) -\u003e CacheEffect | None:\r\n ^\r\nparser.py:241: error: Missing return statement [return]\r\n def stack_effect(self) -\u003e StackEffect | None:\r\n ^\r\nparser.py:249: error: Module has no attribute \"IF\" [attr-defined]\r\n if self.expect(lx.IF):\r\n ^~~~~\r\nparser.py:284: error: Missing return statement [return]\r\n def super_def(self) -\u003e Super | None:\r\n ^\r\nparser.py:295: error: Missing return statement [return]\r\n def ops(self) -\u003e list[OpName] | None:\r\n ^\r\nparser.py:304: error: Missing return statement [return]\r\n def op(self) -\u003e OpName | None:\r\n ^\r\nparser.py:309: error: Missing return statement [return]\r\n def macro_def(self) -\u003e Macro | None:\r\n ^\r\nparser.py:320: error: Missing return statement [return]\r\n def uops(self) -\u003e list[UOp] | None:\r\n ^\r\nparser.py:328: error: Incompatible return value type (got \"List[Node]\", expected\r\n\"Optional[List[Union[OpName, CacheEffect]]]\") [return-value]\r\n return uops\r\n ^~~~\r\nparser.py:331: error: Missing return statement [return]\r\n def uop(self) -\u003e UOp | None:\r\n ^\r\nparser.py:384: error: Missing return statement [return]\r\n def block(self) -\u003e Block | None:\r\n ^\r\ngenerate_cases.py:395: error: Item \"None\" of \"Optional[Context]\" has no attribute\r\n\"owner\" [union-attr]\r\n filename = context.owner.filename\r\n ^~~~~~~~~~~~~\r\ngenerate_cases.py:598: error: Incompatible types in assignment (expression has type\r\n\"Optional[Node]\", variable has type \"Union[InstDef, Super, Macro, Family, None]\") \r\n[assignment]\r\n while thing := psr.definition():\r\n ^~~~~~~~~~~~~~~~\r\ngenerate_cases.py:664: error: Item \"None\" of \"Optional[Family]\" has no attribute\r\n\"name\" [union-attr]\r\n f\"Instruction {member} is a member of multiple f...\r\n ^\r\ngenerate_cases.py:675: error: Item \"None\" of \"Optional[Family]\" has no attribute\r\n\"name\" [union-attr]\r\n f\"Component {part.instr.name} of macro {...\r\n ^\r\ntest_generator.py:46: error: Missing positional argument \"metadata_filename\" in call\r\nto \"Analyzer\" [call-arg]\r\n a = generate_cases.Analyzer(temp_input.name, temp_output.name)\r\n ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\ntest_generator.py:46: error: Argument 1 to \"Analyzer\" has incompatible type \"str\";\r\nexpected \"List[str]\" [arg-type]\r\n a = generate_cases.Analyzer(temp_input.name, temp_output.name)\r\n ^~~~~~~~~~~~~~~\r\nFound 24 errors in 3 files (checked 5 source files)\r\n```\r\n\r\nIf @gvanrossum finds it useful, I can surely work on this.\r\nCC @AlexWaygood \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-108090\n* gh-108112\n* gh-108454\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2023-05-15T10:21:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/104504/cpython/issues/104504"}
| 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:6deac4da-cf4f-e866-b218-b2e1fa0c5ce2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD5E:366DBA:18520F8:20894EC:6969AB96 |
| html-safe-nonce | fc16eb56081858166ce13f4dcb21634b0a82365b7dbc0e00c8a5106605c6081c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDVFOjM2NkRCQToxODUyMEY4OjIwODk0RUM6Njk2OUFCOTYiLCJ2aXNpdG9yX2lkIjoiMTUzNTAyMDk2NTQ2NjU4MTkxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 40a99476a6a431b5ff5207b0b06b0752f9c6d07a7befc614e62925bd1877ed71 |
| hovercard-subject-tag | issue:1709783934 |
| 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/cpython/104504/issue_layout |
| twitter:image | https://opengraph.githubassets.com/870482687f95049ab727b24540d9992920cde81e6c8617facfd774d48f42938e/python/cpython/issues/104504 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/870482687f95049ab727b24540d9992920cde81e6c8617facfd774d48f42938e/python/cpython/issues/104504 |
| og:image:alt | Feature or enhancement After #104421 is merged, we now have the precedent and the needed infrastructure to run mypy on things that support type annotations in Tools/ Pitch Maybe we should run it on... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width