The problem is that mypy's knowledge of read_file_lines is not precise enough, or perhaps outright wrong. The type annotation on read_file_lines.__iter__ says that it's an Iterator[str], but it's actually an iterator over bytes when the context manager was initialized with binary=True. Earlier versions of mypy were fine with that, but since mypy 0.960, they're complaining, I think rightfully, I think thanks to improvements in how overloads for open are handled.
The code isn't wrong, but it has a dependent type, which is too hard for mypy.
The goal of this issue is to fix macro_collector.py so that our code typechecks under modern mypy.
scripts/mbedtls_framework/macro_collector.py
fails to typecheck with mypy ≥0.960.The problem is that mypy's knowledge of
read_file_lines
is not precise enough, or perhaps outright wrong. The type annotation onread_file_lines.__iter__
says that it's anIterator[str]
, but it's actually an iterator overbytes
when the context manager was initialized withbinary=True
. Earlier versions of mypy were fine with that, but since mypy 0.960, they're complaining, I think rightfully, I think thanks to improvements in how overloads foropen
are handled.The code isn't wrong, but it has a dependent type, which is too hard for mypy.
The goal of this issue is to fix
macro_collector.py
so that our code typechecks under modern mypy.