11import contextlib
22import inspect
3+ import warnings
34from collections .abc import Callable , Sequence
5+ from pathlib import Path
46from typing import Any
57
6- from unrealsdk import logging
7-
88from mods_base import BaseOption , GroupedOption , Mod , NestedOption
99from save_options .options import SaveOption
1010
2020
2121registered_mods : dict [str , Mod ] = {}
2222
23+ _WARNING_SKIPS : tuple [str ] = (str (Path (__file__ ).parent ),)
24+
2325
2426def _treat_as_save_option (obj : Any ) -> bool :
2527 """
@@ -46,9 +48,11 @@ def _treat_as_save_option(obj: Any) -> bool:
4648 if all (_treat_as_save_option (child ) for child in obj .children ):
4749 return True
4850 if any (_treat_as_save_option (child ) for child in obj .children ):
49- logging . dev_warning (
51+ warnings . warn (
5052 f"Option { obj .identifier } has both regular BaseOption and SaveOption"
5153 f" defined as children. SaveOption instances will be ignored." ,
54+ stacklevel = 2 ,
55+ skip_file_prefixes = _WARNING_SKIPS ,
5256 )
5357 return False
5458
@@ -107,13 +111,19 @@ def register_save_options( # noqa: C901, D417
107111 if _treat_as_save_option (option ):
108112 new_save_options .append (option )
109113 else :
110- logging .dev_warning (f"Cannot register { option } as a SaveOption" )
114+ warnings .warn (
115+ f"Cannot register { option } as a SaveOption" ,
116+ stacklevel = 2 ,
117+ skip_file_prefixes = _WARNING_SKIPS ,
118+ )
111119 else :
112120 for _ , value in inspect .getmembers (module ):
113121 if isinstance (value , GroupedOption | NestedOption ):
114- logging .dev_warning (
115- f"{ module .__name__ } : { type (value ).__name__ } instances must be explicitly"
116- f" specified in the options list!" ,
122+ warnings .warn (
123+ f"{ type (value ).__name__ } instances must be explicitly specified in the options"
124+ f" list!" ,
125+ stacklevel = 2 ,
126+ skip_file_prefixes = _WARNING_SKIPS ,
117127 )
118128 elif _treat_as_save_option (value ):
119129 new_save_options .append (value )
0 commit comments