Skip to content

Commit 06458a7

Browse files
authored
Silencing schema_to_class.py warnings by default AND making the toggle for them method arguments, so they can be turned on/off normally (#726)
1 parent d768d1f commit 06458a7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

emod_api/schema_to_class.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55
from collections import OrderedDict
66

77
schema_cache = None
8-
show_warnings = True
98

109

11-
def disable_warnings():
12-
"""
13-
Turn off warnings to console. These can get very verbose.
14-
"""
15-
show_warnings = False
16-
1710
class ReadOnlyDict(OrderedDict):
1811
def __missing__(self, key):
1912
raise KeyError(f"'{key}' not found in this object. List of keys = {self.keys()}.")
@@ -111,7 +104,7 @@ def to_file(self, config_name="config.json"):
111104
with open( config_name, "w" ) as config_file:
112105
json.dump( config, config_file, indent=4, sort_keys=True )
113106

114-
def finalize(self):
107+
def finalize(self, show_warnings: bool = False):
115108
"""
116109
Remove all params that are disabled by depends-on param being off and schema node.
117110
"""
@@ -212,7 +205,8 @@ def get_schema( schema_path=None ):
212205
schema = schema_cache
213206
return schema
214207

215-
def get_class_with_defaults( classname, schema_path=None ):
208+
209+
def get_class_with_defaults(classname, schema_path=None, show_warnings: bool = False):
216210
"""
217211
Returns the default config for a datatype in the schema.
218212
"""

0 commit comments

Comments
 (0)