Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt quotes around type names to make Reader ex. copy/paste-ready #340

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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