Incorrect type annotations and mypy ≥0.960 failure in macro_collector.py #50
Labels
No labels
approved
bug
dependencies
DO-NOT-MERGE
enhancement
good-first-issue
help-wanted
historical-reviewed
historical-reviewing
needs-adoption
needs-ci
needs-design-approval
needs-info
needs-preceding-pr
needs-review
needs-reviewer
needs-work
priority-high
priority-low
priority-medium
priority-scheduled
priority-very-high
single-reviewer
size-l
size-m
size-s
size-xs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Mbed-TLS/mbedtls-framework#50
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
scripts/mbedtls_framework/macro_collector.pyfails to typecheck with mypy ≥0.960.The problem is that mypy's knowledge of
read_file_linesis 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 overbyteswhen 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 foropenare 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.pyso that our code typechecks under modern mypy.