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 used and also increase the total coverage of codebase.
Unfortunately when we are using extensively TypeDicts, we have noticed that the coverage stays the same after applying to the code.
The 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
NOTE: At the same time if we convert everything to inline type, then the coverage will be proper 100%.
To Reproduce
from __future__ import annotations
__all__ = ['ChannelTypedDict']
import typing as t
class _RecipientTypedDict(t.TypedDict):
to: list[str]
cc: list[str]
bcc: list[str]
class _DataTypedDict(t.TypedDict):
recipients: _RecipientTypedDict
subject: str
message: str
class ChannelTypedDict(t.TypedDict):
medium: t.Literal['email']
data: _DataTypedDict
Expected Behavior
The file with TypedDict definitions should be covered accordingly (in most cases it should have 100% coverage)
Actual Behavior
The file containing TypedDict usually has 50% coverage or around (usually we put types outside of main codebase)
Your Environment
- Mypy version used:
mypy 1.10.1 (compiled: no)
- Mypy command-line flags:
--cache-fine-grained
(as we are running it withdmypy
) - Mypy configuration options from
mypy.ini
(and other config files):
txt_report = "src/mypy-reports"
html_report = "src/mypy-reports"
plugins = [
"mypy_django_plugin.main",
"mypy_drf_plugin.main",
"pydantic.mypy",
]
strict = true
warn_unreachable = true
ignore_missing_imports = true
- Python version used:
Python 3.11.9