Settings: warn for broken worlds instead of crashing (#4438)

note: i swear the issue was an importerror but i could only get attributeerrors on the getattr() call, maybe we want to check for both?
This commit is contained in:
qwint
2025-08-10 10:23:39 -05:00
committed by GitHub
parent c34c00baa4
commit cdde38fdc9

View File

@@ -754,7 +754,12 @@ class Settings(Group):
return super().__getattribute__(key)
# directly import world and grab settings class
world_mod, world_cls_name = _world_settings_name_cache[key].rsplit(".", 1)
try:
world = cast(type, getattr(__import__(world_mod, fromlist=[world_cls_name]), world_cls_name))
except AttributeError:
import warnings
warnings.warn(f"World {world_cls_name} failed to initialize properly.")
return super().__getattribute__(key)
assert getattr(world, "settings_key") == key
try:
cls_or_name = world.__annotations__["settings"]