Title: Question: Can I get mypy to type check in "strict and safe" as opposed to "best effort" style? · Issue #2780 · python/mypy · GitHub
Open Graph Title: Question: Can I get mypy to type check in "strict and safe" as opposed to "best effort" style? · Issue #2780 · python/mypy
X Title: Question: Can I get mypy to type check in "strict and safe" as opposed to "best effort" style? · Issue #2780 · python/mypy
Description: I don't know how typical a user of mypy I am, in that the thing I am using it for is to lean on its type system to give me feedback about a complex new program from the beginning, as opposed to retrofitting types onto an existing project...
Open Graph Description: I don't know how typical a user of mypy I am, in that the thing I am using it for is to lean on its type system to give me feedback about a complex new program from the beginning, as opposed to ret...
X Description: I don't know how typical a user of mypy I am, in that the thing I am using it for is to lean on its type system to give me feedback about a complex new program from the beginning, as opposed to...
Opengraph URL: https://github.com/python/mypy/issues/2780
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Question: Can I get mypy to type check in \"strict and safe\" as opposed to \"best effort\" style?","articleBody":"I don't know how typical a user of mypy I am, in that the thing I am using it for is to lean on its type system to give me feedback about a complex new program from the beginning, as opposed to retrofitting types onto an existing project to look for bugs in it. In my case, false negatives (i.e., failing to type check something, or silently giving something the wrong type) are much worse than false positives (loudly claiming a type error in code that actually executes fine). I am also willing to adjust my program to a considerable degree to make it type-check, in part because I expect the result to be easier to read as well (and in part because I am used to programming in Haskell). In return for that, I am looking for confidence that the program does not commit type errors, and therefore the architecture is reasonably sound, at least at the type level.\r\n\r\nI can, however, imagine a large community of mypy users that are trying to use mypy to look for type errors in large existing programs, presumably incrementally. In this case, false positives are very problematic, because too many too early would make the task of typing a program too difficult up front, without showing enough value early enough to make it seem worth it. In light of this use case, I can certainly understand that mypy would lean toward admitting false negatives to reduce the rate of false positives by default (silently skipping non-annotated functions, silently inserting the Any type, etc).\r\n\r\nMy question is this: Is mypy intended to support the \"no false negatives\" use style? If so, how can I get it to be as aggressive as possible? I already found `--strict-optional --disallow-untyped-calls --check-untyped-defs`, but those seem like isolated \"stricter\" decisions in a sea of \"best effort\" defaults. Ideally, I would like to get mypy to complain loudly about every little place where some construct is problematic. \r\n\r\nOne specific example is Issue #2776. That is a situation where the \"right thing to do\" depends on whether the user wants to avoid false positives or false negatives. It is also a sufficiently specific situation that it probably doesn't warrant a command line flag of its own, but it could reasonably be influenced by a global `--avoid-false-negatives` flag.\r\n\r\nFull disclosure: my real use case is a mixture. The reason I am writing the program I want to type check so strictly in Python in the first place is because I want it to be able to call out to a substantial pile of (not type-checked) Python code my research group has already written (which I am willing to add type annotations to, and to modify locally, but less willing to substantially refactor based on feedback from the type checker). So what I really want is per-file or per-function selection of whether to prefer a low false-negative or a low false-positive rate; but I can make do with a global setting :)","author":{"url":"https://github.com/axch","@type":"Person","name":"axch"},"datePublished":"2017-01-31T12:11:39Z","url":"https://github.com/python/mypy/issues/2780"}
| 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:29f0ff19-23ce-6323-6b09-8c35a66924e5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2A4:1AC37C:4D4DB3:67A557:6B002F4C |
| html-safe-nonce | fd605fcd00aff2ea7dc0ed0be70ae25fe0966325115d4963c84adca6d5e896bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkE0OjFBQzM3Qzo0RDREQjM6NjdBNTU3OjZCMDAyRjRDIiwidmlzaXRvcl9pZCI6IjcxNTQ4ODI0Mzg0NzUyOTY1ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bed0ff200b860e6fbd2944ee3972cc44e1c82ea28fed5d2ce5e116b4e04fab4e |
| hovercard-subject-tag | issue:204278147 |
| 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/2780/issue_layout |
| twitter:image | https://opengraph.githubassets.com/442e23ca075859e1ffc9d104c84c5ca36ed32960c400d0ceba314db24f1968b6/python/mypy/issues/2780 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/442e23ca075859e1ffc9d104c84c5ca36ed32960c400d0ceba314db24f1968b6/python/mypy/issues/2780 |
| og:image:alt | I don't know how typical a user of mypy I am, in that the thing I am using it for is to lean on its type system to give me feedback about a complex new program from the beginning, as opposed to ret... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | axch |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width