Skip to content

Commit

Permalink
refactor: better handling of plugin types for ModelHook manager
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 authored and aaraney committed Jul 25, 2024
1 parent 4f4c740 commit d8c66e8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/ngen_cal/src/ngen/cal/_plugin_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ def setup_plugin_manager(plugins: list[Callable | ModuleType]) -> PluginManager:

return pm

def setup_scoped_plugin_manager(spec: type, plugins: list[Callable | ModuleType]) -> PluginManager:
def setup_scoped_plugin_manager(spec: type, plugins: list[Callable]) -> PluginManager:
pm = pluggy.PluginManager(PROJECT_SLUG)
pm.add_hookspecs(spec)

for plugin in plugins:
assert not isinstance(plugin, ModuleType), "function plugins"
if isinstance(plugin, Callable):
pm.register(plugin())
elif isinstance(plugin, ModuleType):
pm.register(plugin)
else:
assert_never(plugin)

Expand Down

0 comments on commit d8c66e8

Please sign in to comment.