mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-20 20:01:31 -06:00
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:
@@ -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"]
|
||||
|
Reference in New Issue
Block a user