This is a follow-up for #5231
With #5231 the import of an arbitrary module from a package contains a __getattr__ that returns either Any or types.ModuleType. It would be good to add a better error message about a missing import if the error appears because of a wrong return type of __getattr__.