Skip to content

Commit

Permalink
Adopt quotes around type names to make Reader ex. copy/paste-ready (#340
Browse files Browse the repository at this point in the history
)

napari/docs#367 (review)
napari/docs#365

---------

Co-authored-by: Draga Doncila Pop <[email protected]>
  • Loading branch information
vreuter and DragaDoncila authored Mar 22, 2024
1 parent c16fb42 commit 0e7466a
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit 0e7466a

Please sign in to comment.