Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions _docs/example_plugin/some_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from magicgui import magic_factory
from qtpy.QtWidgets import QWidget

from npe2.types import LayerData, PathOrPaths, ReaderFunction

if TYPE_CHECKING:
import napari.types
import napari.viewer
from npe2.types import LayerData, PathOrPaths, ReaderFunction


def write_points(path: str, layer_data: Any, attributes: Dict[str, Any]) -> List[str]:
Expand All @@ -20,15 +19,15 @@ def write_points(path: str, layer_data: Any, attributes: Dict[str, Any]) -> List
return [path]


def get_reader(path: PathOrPaths) -> Optional[ReaderFunction]:
def get_reader(path: "PathOrPaths") -> Optional["ReaderFunction"]:
# If we recognize the format, we return the actual reader function
if isinstance(path, str) and path.endswith(".xyz"):
return xyz_file_reader
# otherwise we return None.
return None


def xyz_file_reader(path: PathOrPaths) -> List[LayerData]:
def xyz_file_reader(path: "PathOrPaths") -> List["LayerData"]:
data = ... # somehow read data from path
layer_attributes = {"name": "etc..."}
return [(data, layer_attributes)]
Expand Down Expand Up @@ -64,7 +63,7 @@ def threshold(
return (image > threshold).astype(int)


def create_fractal() -> List[LayerData]:
def create_fractal() -> List["LayerData"]:
"""An example of a Sample Data Function.

Note: Sample Data with URIs don't need python code.
Expand Down