protocols_modules error

Module assigned to incompatible protocol type

When a module object is assigned to a variable typed as a Protocol, the module's public interface must be compatible with the protocol. This rule detects assignments of the form:

import some_module

class MyProtocol(Protocol):
    timeout: str

x: MyProtocol = some_module  # E — some_module.timeout is int, not str

This is a simplified check: if the annotation names a class that inherits from Protocol and the RHS is a module name, the assignment is flagged when the module is known to be incompatible.

Specification: <https://typing.readthedocs.io/en/latest/spec/protocol.html#modules-as-implementations-of-protocols>

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial protocols_modules down per-file or per-path from your editor or pyproject.toml, or fix the code so it type-checks. See the Type System rules and the complete diagnostic reference.

Canonical URL: https://www.basilisk-python.dev/errors/protocols_modules