imports_module_attribute
error
Access to a module attribute the local stub does not declare
When import X resolves to a **user/local stub** (a .pyi under a configured stub-paths dir, including the auto-discovered .basilisk/stubs), that stub is authoritative: Basilisk only knows the names it declares. So X.attr where attr is not declared is a hard error — the counterpart that makes a hand-written or quick-fix-generated stub mean something.
The escape hatch is the module-level def __getattr__(name: str) -> Any: ... that the "Create local type stub" quick fix ships by default: keep it and every attribute is allowed (the module stays Any); remove it and declare specific symbols, and undeclared access is flagged.
import cowsay # resolves to .basilisk/stubs/cowsay.pyi
cowsay.get_output_string(...) # E0154 if the stub declares neither this nor __getattr__
Scope (Phase 1): only plain, single-segment import X backed by a user stub. imported_modules is populated only for those, so this rule is a complete no-op for code without local stubs (the conformance suite, first-party code), keeping the false-positive surface at zero.
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
imports_module_attribute 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/imports_module_attribute