Skip to content

Conversation

@jorenham
Copy link

@jorenham jorenham commented Jan 27, 2026

This configures mypy to run in "strict mode", which according to mypy --help enables the following flags:

--warn-unused-configs, --disallow-any-generics, --disallow-subclassing-any, --disallow-untyped-calls, --disallow-untyped-defs, --disallow-incomplete-defs, --check-untyped-defs, --disallow-untyped-decorators, --warn-redundant-casts, --warn-unused-ignores, --warn-return-any, --no-implicit-reexport, --strict-equality,
--strict-bytes, --extra-checks

Enabling this caused a bunch of typing errors to surface, which are now also fixed.

Most of these are related to bytes/bytearray/memoryview not being assignable to each other. So I used their common denominator, collections.abc.Buffer, or rather its backport from typing_extensions (which is always available if TYPE_CHECKING because typeshed conveniently lies that it's part of the standard library).

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
disallow_untyped_calls = false
enable_error_code = "ignore-without-code"
extra_checks = true
follow_imports = "silent"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything at https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-strict that mentions follow_imports? What was the thinking behind changing this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, follow_imports is unrelated to --strict. It's just unnecessary to suppress those import errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants