Title: Rewrite .test as .py · Issue #15326 · python/mypy · GitHub
Open Graph Title: Rewrite .test as .py · Issue #15326 · python/mypy
X Title: Rewrite .test as .py · Issue #15326 · python/mypy
Description: Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files? I've been musing about it for a while, so hear me out, then let me ...
Open Graph Description: Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files? I've been musing about it f...
X Description: Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files? I've been musing about ...
Opengraph URL: https://github.com/python/mypy/issues/15326
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rewrite .test as .py","articleBody":"Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files?\r\n\r\nI've been musing about it for a while, so hear me out, then let me know if it's a stupid idea :)\r\n\r\nExample:\r\n\r\n```diff\r\n-[case testFoo]\r\n-s1: str = 42 # E: Incompatible types in assignment (expression has type \"int\", variable has type \"str\")\r\n+def test_foo():\r\n+ s1: str = 42 # E: Incompatible types in assignment (expression has type \"int\", variable has type \"str\")\r\n```\r\n\r\nTo clarify, this wouldn't be true Python code, i.e. it won't be fed directly to CPython or Mypy; rather, it'll be a Python-flavored data file — perhaps parsed by AST (if feasible and performant), but where the function bodies are passed to the current machinery as text.\r\n\r\nExtra qualifies like `# flags: --strict-optional` could be represented as decorators, e.g.\r\n```python\r\n@flags('--strict-optional')\r\ndef test_foo():\r\n ...\r\n```\r\n\r\n`[case testFoo-xfail]` would become:\r\n```python\r\n@pytest.mark.xfail\r\ndef test_foo():\r\n ...\r\n```\r\n\r\n`[out]` would become:\r\n```python\r\n@expected_output(\"\"\"\r\nmain:1: Incompatible types in assignment (expression has type \"int\", variable has type \"str\")\r\n\"\"\")\r\ndef test_foo():\r\n ...\r\n```\r\n\r\n`[file a.py]` would become:\r\n```python\r\n@testcase\r\ndef test_foo():\r\n ... # main goes here\r\n\r\n\r\n@test_foo.file('a.py')\r\ndef test_foo():\r\n ... # a.py goes here\r\n```\r\n\r\nBenefits:\r\n- First-class support in IDEs, e.g. \r\n \r\n \r\n- The disarray of testcase options, sections and modifiers could be formalized in a Pythonic syntax and a module that would document them, e.g. `from mypy.testcase import expected_output` and then\r\n ```python\r\n # mypy/testcase.py\r\n\r\n def expected_output(output: str) -> Testcase:\r\n \"\"\"Documentation goes here\"\"\"\r\n ... \r\n ````\r\n- Can use some Python tooling like Black\r\n- A more flexible representation than INI, while providing first-class editor experience (unlike, say, converting to YAML and putting the Python test cases into a multiline YAML block).\r\n- More natural for newcomers?\r\n\r\nCons:\r\n- Harder to implement?\r\n- Confusing that it's Python but not really?\r\n- Less natural to newcomers?\r\n","author":{"url":"https://github.com/ikonst","@type":"Person","name":"ikonst"},"datePublished":"2023-05-30T19:16:59Z","url":"https://github.com/python/mypy/issues/15326"}
| 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:c3347759-b36a-3aea-8b03-ff65f1dfb51e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A2BE:182C25:BC53D9:FC5BBD:6B004E53 |
| html-safe-nonce | 3e199d1d988fcd8d051d5acbcd1118116e5a9d1c96f8e74ea01d6b611c7d7741 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkJFOjE4MkMyNTpCQzUzRDk6RkM1QkJEOjZCMDA0RTUzIiwidmlzaXRvcl9pZCI6IjQ4MzIyMzIyODU5Mjk0OTIwNTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5a70d1b5c8c496a98dac9135dd14fec6b200360186121929f957ac674028e359 |
| hovercard-subject-tag | issue:1732838937 |
| 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/15326/issue_layout |
| twitter:image | https://opengraph.githubassets.com/544c7e319deb5851bd90cf67374f7d98b89bd99f8369ff306cb87ac5fdf4b061/python/mypy/issues/15326 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/544c7e319deb5851bd90cf67374f7d98b89bd99f8369ff306cb87ac5fdf4b061/python/mypy/issues/15326 |
| og:image:alt | Many of us are using editors that handle Python code (syntax highlighting, symbol browsing). Would it be a good idea to restructure the .test data-files as Python files? I've been musing about it f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ikonst |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width