Title: bug: strict = true is incompatible with per-module configuration · Issue #11401 · python/mypy · GitHub
Open Graph Title: bug: strict = true is incompatible with per-module configuration · Issue #11401 · python/mypy
X Title: bug: strict = true is incompatible with per-module configuration · Issue #11401 · python/mypy
Description: To Reproduce Create the following file structure: my_module/__init__.py tests/__init__.py mypy.ini Both my_module/__init__.py and tests/__init__.py contain: def untyped(): ... Which should trigger an error when run with strict but otherw...
Open Graph Description: To Reproduce Create the following file structure: my_module/__init__.py tests/__init__.py mypy.ini Both my_module/__init__.py and tests/__init__.py contain: def untyped(): ... Which should trigger ...
X Description: To Reproduce Create the following file structure: my_module/__init__.py tests/__init__.py mypy.ini Both my_module/__init__.py and tests/__init__.py contain: def untyped(): ... Which should trigger ...
Opengraph URL: https://github.com/python/mypy/issues/11401
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: strict = true is incompatible with per-module configuration","articleBody":"**To Reproduce**\r\n\r\nCreate the following file structure:\r\n\r\n```\r\nmy_module/__init__.py\r\ntests/__init__.py\r\nmypy.ini\r\n```\r\n\r\nBoth `my_module/__init__.py` and `tests/__init__.py` contain:\r\n\r\n```python\r\ndef untyped():\r\n ...\r\n```\r\n\r\nWhich should trigger an error when run with `strict` but otherwise pass.\r\n\r\nIn `mypy.ini`:\r\n\r\n```\r\n[mypy]\r\nstrict = true\r\n[mypy-tests.*]\r\nstrict = false\r\n```\r\n\r\nThat is, I want strict mode in my source code but not my tests.\r\n\r\nThen I run this using `mypy .`\r\n\r\n**Expected Behavior**\r\n\r\nI expect to get an error for my source code but not my tests:\r\n\r\n```\r\nmy_module/__init__.py:1: error: Function is missing a return type annotation\r\nmy_module/__init__.py:1: note: Use \"-> None\" if function does not return a value\r\n```\r\n\r\n**Actual Behavior**\r\n\r\nI get an error for both my source code and tests.\r\nIt seems like `strict = False` in the per module section is ignored.\r\n\r\n```\r\ntests/__init__.py:1: error: Function is missing a return type annotation\r\ntests/__init__.py:1: note: Use \"-> None\" if function does not return a value\r\nmy_module/__init__.py:1: error: Function is missing a return type annotation\r\nmy_module/__init__.py:1: note: Use \"-> None\" if function does not return a value\r\n```\r\n\r\nIf I add an explicit `allow_untyped_defs = True` to the `mypy-tests.*` section:\r\n\r\n```\r\n[mypy]\r\nstrict = true\r\n[mypy-tests.*]\r\nstrict = false\r\nallow_untyped_defs = True\r\n```\r\n\r\nThat seems to be processed fine (I now get no errors for my tests but still get errors for my source).\r\nSo I believe the config file is valid, mypy is picking up that the options only apply to `tests.*`.\r\n\r\nI also tried flipping the enable/disable:\r\n\r\n```\r\n[mypy]\r\nstrict = false\r\n[mypy-my_module.*]\r\nstrict = true\r\n```\r\n\r\nBut I get the same result.\r\n\r\nThis also seems to be the case with `pyproject.toml` configs.","author":{"url":"https://github.com/adriangb","@type":"Person","name":"adriangb"},"datePublished":"2021-10-28T16:07:36Z","url":"https://github.com/python/mypy/issues/11401"}
| 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:de11bef2-3c1a-274f-fa62-1b714264adcb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8096:5314B:2EE66FE:3DF4834:6B00287D |
| html-safe-nonce | c8f8da99633a0552aad4b5e2ec8912b1e77c98646cf5a143266cf2426bf610b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDk2OjUzMTRCOjJFRTY2RkU6M0RGNDgzNDo2QjAwMjg3RCIsInZpc2l0b3JfaWQiOiIzNzc3NzU0OTk2NTY5ODExMDY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 24aab23aa6fe9acc2576a8c8b42f628f24cdf3ea2e5761f30f6e97a89127a48f |
| hovercard-subject-tag | issue:1038692457 |
| 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/11401/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49276335b662c71597aabe27f2f95e7375e7057bb13144bf059ed6f0e67b57ae/python/mypy/issues/11401 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49276335b662c71597aabe27f2f95e7375e7057bb13144bf059ed6f0e67b57ae/python/mypy/issues/11401 |
| og:image:alt | To Reproduce Create the following file structure: my_module/__init__.py tests/__init__.py mypy.ini Both my_module/__init__.py and tests/__init__.py contain: def untyped(): ... Which should trigger ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adriangb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width