9
9
10
10
import gettext
11
11
import os
12
+ from typing import Optional
12
13
13
14
from jinja2 import Environment , FileSystemLoader
14
15
from jupyter_server .base .handlers import FileFindHandler , path_regex
@@ -53,20 +54,24 @@ def _jupyter_server_extension_points():
53
54
return [{"module" : "voila.server_extension" }]
54
55
55
56
56
- def load_config_file () -> Config :
57
+ def load_config_file () -> Optional [ Config ] :
57
58
"""
58
59
Loads voila.json and voila.py config file from current working
59
60
directory and other Jupyter paths
60
61
"""
61
62
62
- new_config = Config ()
63
+ new_config = None
63
64
base_file_name = "voila"
64
65
config_file_paths = [* jupyter_config_path (), os .getcwd ()]
65
66
66
67
for current in config_file_paths :
67
68
py_loader = PyFileConfigLoader (filename = f"{ base_file_name } .py" , path = current )
68
69
try :
69
70
py_config = py_loader .load_config ()
71
+
72
+ if new_config is None :
73
+ new_config = Config ()
74
+
70
75
new_config .merge (py_config )
71
76
except ConfigFileNotFound :
72
77
pass
@@ -76,6 +81,10 @@ def load_config_file() -> Config:
76
81
)
77
82
try :
78
83
json_config = json_loader .load_config ()
84
+
85
+ if new_config is None :
86
+ new_config = Config ()
87
+
79
88
new_config .merge (json_config )
80
89
except ConfigFileNotFound :
81
90
pass
@@ -88,7 +97,10 @@ def _load_jupyter_server_extension(server_app: ServerApp):
88
97
# common configuration options between the server extension and the application
89
98
90
99
voila_configuration = VoilaConfiguration (parent = server_app )
91
- voila_configuration .config .merge (load_config_file ())
100
+
101
+ local_config = load_config_file ()
102
+ if local_config is not None :
103
+ voila_configuration .config .merge (load_config_file ())
92
104
93
105
template_name = voila_configuration .template
94
106
template_paths = collect_template_paths (["voila" , "nbconvert" ], template_name )
0 commit comments