Lookup chain from a dataclass field with a string annotation through dataclasses._is_type to sys.modules: unregistered, the by-name lookup returns None and .__dict__ raises AttributeError; registered first, the same lookup finds the module and the class builds.
Python

A NoneType AttributeError inside dataclasses means your importlib-loaded module is missing from sys.modules

Loading a .py by path crashes in dataclasses._is_type when it uses future annotations. The fix: sys.modules[spec.name] = mod before exec_module.