Skip to content

Commit b331ff2

Browse files
committed
Defer .cbi/config loading until required
Loading the configuration file when the module is imported can lead to a situation where an exception is thrown before logging is configured. Signed-off-by: John Pennycook <[email protected]>
1 parent 566a0a6 commit b331ff2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

codebasin/config.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ def _load_compilers():
249249
compiler.passes[name] = _CompilerPass.from_toml(p)
250250

251251

252-
# Load the compiler configuration when this module is imported.
253-
if not _compilers:
254-
_load_compilers()
255-
256-
257252
@dataclass
258253
class PreprocessorConfiguration:
259254
"""
@@ -293,6 +288,10 @@ class ArgumentParser:
293288
def __init__(self, path: str):
294289
self.name = os.path.basename(path)
295290

291+
# Load the global compiler configuration if necessary.
292+
if not _compilers:
293+
_load_compilers()
294+
296295
self.compiler = _Compiler()
297296
if self.name not in _compilers:
298297
log.warning(f"Compiler '{self.name}' not recognized.")

0 commit comments

Comments
 (0)