cookiecutter-napari-plugin
cookiecutter-napari-plugin copied to clipboard
npe2 cookiecutter notes
hey @nclack
Taking a look through the npe2 cookiecutter, instead of a PR, just want to put some tasks here that we can tackle individually:
- [x] we shouldn't use
from numpy.typing import ArrayLikein_writerfor two reasons: first, it's only available in pretty new versions of numpy (I think 1.20+) and we didn't pin numpy in the users' setup.cfg. Second, it's not an accurate type., layer data can come in many types. We're trying to codify this with the LayerDataProtocol, but i wouldn't use that either. Just call ittyping.Anyfor now. - [ ] writers need more docstrings with clearer expectations about what they expect, and what they should do. I know there's a link there, but it would be nice if the cookiecutter stood alone a bit more.
- [x] #71
anddef write_single_image(path: str, data: Any): ... # should be changed to def write_single_image(path: str, data: Any, meta: dict): ...
The args are passed heredef write_multiple(path: str, data: List[ArrayLike], layer_types: List[str]): ... # should be change to def write_multiple(path: str, List[FullLayerData]): ... - [x] ... obviously, we should make the equivalent of the
hook_specifications.pyfor npe2, so we have one authoritative place to look for all signatures expected by npe2. (See https://github.com/napari/npe2/pull/61) - [x] #70
commands: - id: napari-foobar.get_reader python_name: napari_foobar._reader:napari_get_reader title: Open data with napari FooBar - id: napari-foobar.writer python_name: napari_foobar._reader:napari_get_reader title: Save data with napari FooBar - [x] (This one is in main like this, but just noting this so I don't forget)... in
_widget.py, we should preferviewer: 'napari.viewer.Viewer'over using the param namednapari_viewer, and we should add at the top:
if TYPE_CHECKING:
import napari.viewer
import napari.layers
- [ ] writer tests need improvement (possible others as well)
the equivalent of the hook_specifications.py for npe2
I like it a lot
the writer test is anemic/not-present which contributes to some of these. I let that slip my mind. I'll edit the issue to add that to the list.
I'll close this issue as most of the issues are probably out of date. We can make new issues (better writer docs and tests) as they surface in napari/napari-plugin-template.