Skip to content

Commit

Permalink
fix precommit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Sep 11, 2024
1 parent b2542f4 commit 979b459
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/npe2/manifest/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def _from_entrypoint(
entry_point: metadata.EntryPoint,
distribution: Optional[metadata.Distribution] = None,
) -> PluginManifest:
assert (match := entry_point.pattern.match(entry_point.value))
match = entry_point.pattern.match(entry_point.value)
assert match is not None
module = match.group("module")

spec = util.find_spec(module or "")
Expand All @@ -397,7 +398,8 @@ def _from_entrypoint(
f"entrypoint: {entry_point.value!r}"
)

assert (match := entry_point.pattern.match(entry_point.value))
match = entry_point.pattern.match(entry_point.value)
assert match is not None
fname = match.group("attr")

for loc in spec.submodule_search_locations or []:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ def test_command_menu_map(uses_sample_plugin, plugin_manager: PluginManager):
assert "my-plugin.another_command" in command_menu_map

# commands point to correct menus
assert len(cmd_menu := command_menu_map["my-plugin.hello_world"]) == 1
cmd_menu = command_menu_map["my-plugin.hello_world"]
assert len(cmd_menu) == 1
assert "/napari/layer_context" in cmd_menu
assert len(cmd_menu := command_menu_map["my-plugin.another_command"]) == 1
cmd_menu = command_menu_map["my-plugin.another_command"]
assert len(cmd_menu) == 1
assert "mysubmenu" in cmd_menu

# enable/disable
Expand Down
6 changes: 4 additions & 2 deletions tests/test_tmp_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def test_temporary_plugin_spawn(tmp_plugin: DynamicPlugin):
assert new.display_name == "another-name"
assert new.plugin_manager == tmp_plugin.plugin_manager

assert (t1 := tmp_plugin.spawn(register=True)).name == f"{tmp_plugin.name}-1"
assert (t2 := tmp_plugin.spawn()).name == f"{tmp_plugin.name}-2"
t1 = tmp_plugin.spawn(register=True)
assert t1.name == f"{tmp_plugin.name}-1"
t2 = tmp_plugin.spawn()
assert t2.name == f"{tmp_plugin.name}-2"

assert t1.name in tmp_plugin.plugin_manager._manifests
assert t2.name not in tmp_plugin.plugin_manager._manifests

0 comments on commit 979b459

Please sign in to comment.