@@ -31,7 +31,6 @@ def _get_pluggin_manager(hook_type: HookType) -> PluginManager:
31
31
def _grouped_hookimpls_results (
32
32
hook : pluggy ._hooks ._HookCaller ,
33
33
) -> Dict [ModuleType , List [Callable ]]:
34
-
35
34
plugins = [impl .plugin for impl in hook .get_hookimpls ()]
36
35
result = hook ()
37
36
assert len (plugins ) == len (result )
@@ -45,15 +44,13 @@ def _grouped_hookimpls_results(
45
44
46
45
47
46
def _load_exceptions_handlers (app : FastAPI ) -> None :
48
-
49
47
pm = _get_pluggin_manager (HookType .EXCEPTION )
50
48
51
49
grouped_exceptions_handlers = _grouped_hookimpls_results (pm .hook .exception_handler )
52
50
53
51
app .add_exception_handler (RedirectException , _redirect_exception_handler )
54
52
55
53
if grouped_exceptions_handlers :
56
-
57
54
pkg_names = {
58
55
get_pkg_name (p , strip_fps = False ) for p in grouped_exceptions_handlers
59
56
}
@@ -62,7 +59,7 @@ def _load_exceptions_handlers(app: FastAPI) -> None:
62
59
for p , exceptions in grouped_exceptions_handlers .items ():
63
60
p_name = Config .plugin_name (p )
64
61
65
- for ( exc_class , exc_handler ) in exceptions :
62
+ for exc_class , exc_handler in exceptions :
66
63
if exc_class in app .exception_handlers :
67
64
logger .error (
68
65
f"Redefinition of handler for '{ exc_class } ' exception is not allowed."
@@ -80,7 +77,6 @@ def _load_exceptions_handlers(app: FastAPI) -> None:
80
77
81
78
82
79
def _load_configurations () -> None :
83
-
84
80
Config .clear_names ()
85
81
Config .clear_models ()
86
82
@@ -97,12 +93,10 @@ def _load_configurations() -> None:
97
93
grouped_plugin_names = _grouped_hookimpls_results (pm .hook .plugin_name )
98
94
99
95
if plugin_name_impls :
100
-
101
96
pkg_names = {get_pkg_name (p , strip_fps = False ) for p in grouped_plugin_names }
102
97
logger .info (f"Loading names from plugin package(s) { pkg_names } " )
103
98
104
99
for p , plugin_names in grouped_plugin_names .items ():
105
-
106
100
if not plugin_names :
107
101
name = Config .register_plugin_name (p )
108
102
elif len (plugin_names ) > 1 :
@@ -131,7 +125,6 @@ def _load_configurations() -> None:
131
125
# config values, and load them from files
132
126
config_impls = pm .hook .config .get_hookimpls ()
133
127
if config_impls :
134
-
135
128
grouped_configs = _grouped_hookimpls_results (pm .hook .config )
136
129
pkg_names = {get_pkg_name (p , strip_fps = False ) for p in grouped_plugin_names }
137
130
logger .info (f"Loading configurations from plugin package(s) { pkg_names } " )
@@ -156,7 +149,6 @@ def _load_configurations() -> None:
156
149
157
150
158
151
def _load_routers (app : FastAPI ) -> None :
159
-
160
152
pm = _get_pluggin_manager (HookType .ROUTER )
161
153
162
154
# Ensure any plugins package has a name registered
@@ -306,7 +298,6 @@ async def __call__(
306
298
307
299
308
300
def create_app ():
309
-
310
301
logging .getLogger ("fps" )
311
302
configure_loggers (logging .root .manager .loggerDict .keys ())
312
303
0 commit comments