Title: Class format of TypedDict does not produce proper coverage · Issue #17477 · python/mypy · GitHub
Open Graph Title: Class format of TypedDict does not produce proper coverage · Issue #17477 · python/mypy
X Title: Class format of TypedDict does not produce proper coverage · Issue #17477 · python/mypy
Description: Bug Report We are using TypedDict to add the proper coverage and proper types for the codebase where the dictionary with pre-defined keys is used. This should solve the problem, add the proper typing everywhere where this dictionary is u...
Open Graph Description: Bug Report We are using TypedDict to add the proper coverage and proper types for the codebase where the dictionary with pre-defined keys is used. This should solve the problem, add the proper typi...
X Description: Bug Report We are using TypedDict to add the proper coverage and proper types for the codebase where the dictionary with pre-defined keys is used. This should solve the problem, add the proper typi...
Opengraph URL: https://github.com/python/mypy/issues/17477
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Class format of TypedDict does not produce proper coverage","articleBody":"**Bug Report**\r\n\r\nWe are using TypedDict to add the proper coverage and proper types for the codebase where the dictionary with pre-defined keys is used. This should solve the problem, add the proper typing everywhere where this dictionary is used and also increase the total coverage of codebase.\r\n\r\nUnfortunately when we are using extensively TypeDicts, we have noticed that the coverage stays the same after applying to the code.\r\n\r\nThe problem is with the coverage of TypedDict itself, even if it has all the types and values specified, mypy somehow flag it as `Any Types on this line`\r\n\r\n_NOTE: At the same time if we convert everything to inline type, then the coverage will be proper 100%._\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\n__all__ = ['ChannelTypedDict']\r\n\r\nimport typing as t\r\n\r\n\r\nclass _RecipientTypedDict(t.TypedDict):\r\n to: list[str]\r\n cc: list[str]\r\n bcc: list[str]\r\n\r\n\r\nclass _DataTypedDict(t.TypedDict):\r\n recipients: _RecipientTypedDict\r\n subject: str\r\n message: str\r\n\r\n\r\nclass ChannelTypedDict(t.TypedDict):\r\n medium: t.Literal['email']\r\n data: _DataTypedDict\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nThe file with TypedDict definitions should be covered accordingly (in most cases it should have 100% coverage)\r\n\r\n**Actual Behavior**\r\n\r\nThe file containing TypedDict usually has 50% coverage or around (usually we put types outside of main codebase)\r\n\u003cimg width=\"55%\" alt=\"Screenshot 2024-07-04 at 01 14 41\" src=\"https://github.com/python/mypy/assets/2711700/811a3553-1c6a-4f5b-82fc-1780ef4715ed\">\u003cimg width=\"45%\" alt=\"Screenshot 2024-07-04 at 01 25 52\" src=\"https://github.com/python/mypy/assets/2711700/058a6b78-1e3c-43d9-a33b-26ce6975e690\">\r\n\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: `mypy 1.10.1 (compiled: no)`\r\n- Mypy command-line flags: `--cache-fine-grained` (as we are running it with `dmypy`)\r\n- Mypy configuration options from `mypy.ini` (and other config files):\r\n```\r\ntxt_report = \"src/mypy-reports\"\r\nhtml_report = \"src/mypy-reports\"\r\nplugins = [\r\n \"mypy_django_plugin.main\",\r\n \"mypy_drf_plugin.main\",\r\n \"pydantic.mypy\",\r\n]\r\nstrict = true\r\nwarn_unreachable = true\r\nignore_missing_imports = true\r\n```\r\n- Python version used: `Python 3.11.9`\r\n","author":{"url":"https://github.com/sshishov","@type":"Person","name":"sshishov"},"datePublished":"2024-07-03T21:28:23Z","url":"https://github.com/python/mypy/issues/17477"}
| 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:8ef8bbcc-56bd-10f6-f896-4db17d763df9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0A6:39827A:1086F7:172523:6B006424 |
| html-safe-nonce | d49b5a1e671530dbd236108a4402238454c2d1c9ca61c76a42c2d1a0b9ebcc2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEE2OjM5ODI3QToxMDg2Rjc6MTcyNTIzOjZCMDA2NDI0IiwidmlzaXRvcl9pZCI6IjUxMDc3ODMwNDU3MjE4NzY4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 60dea39b3a1a5b3a4cf446ac71c31881492b50a4e4d78b72db98c3b7bc0f66bc |
| hovercard-subject-tag | issue:2389516140 |
| 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/17477/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58bd279f1ff552a7b905c6c19f867ba8da629d537ea09e4fc266cda5549e3d59/python/mypy/issues/17477 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58bd279f1ff552a7b905c6c19f867ba8da629d537ea09e4fc266cda5549e3d59/python/mypy/issues/17477 |
| og:image:alt | Bug Report We are using TypedDict to add the proper coverage and proper types for the codebase where the dictionary with pre-defined keys is used. This should solve the problem, add the proper typi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sshishov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 25854482a1773a7c1ebb8be3d2bc1c6e61d82d78126be63b5044474a86d44d9e |
| 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 | e4f5c239e31f1f680e6bbc419ff92d774da616ec |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width