From cdde38fdc9e5f1440249ab8da2cdf8a7edf44ff1 Mon Sep 17 00:00:00 2001 From: qwint Date: Sun, 10 Aug 2025 10:23:39 -0500 Subject: [PATCH] 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? --- settings.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/settings.py b/settings.py index ef1ea9ad..48bc57f0 100644 --- a/settings.py +++ b/settings.py @@ -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) - world = cast(type, getattr(__import__(world_mod, fromlist=[world_cls_name]), world_cls_name)) + 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"]