From 019bcacaa4e7f0c8e4429aa45cd7cc7e6e15861f Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 19 May 2022 18:52:44 +0100 Subject: [PATCH] Increase mypy strictness --- .pre-commit-config.yaml | 1 + README.md | 1 + src/napari_matplotlib/scatter.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6dc5c903..216f555a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,3 +40,4 @@ repos: rev: v0.910-1 hooks: - id: mypy + args: ["--disallow-incomplete-defs", "--ignore-missing-imports"] diff --git a/README.md b/README.md index afcfe6ee..de86a434 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Python Version](https://img.shields.io/pypi/pyversions/napari-matplotlib.svg?color=green)](https://python.org) [![tests](https://github.com/dstansby/napari-matplotlib/workflows/tests/badge.svg)](https://github.com/dstansby/napari-matplotlib/actions) [![codecov](https://codecov.io/gh/dstansby/napari-matplotlib/branch/main/graph/badge.svg)](https://codecov.io/gh/dstansby/napari-matplotlib) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/matplotlib/pytest-mpl/master.svg)](https://results.pre-commit.ci/latest/github/matplotlib/pytest-mpl/master) [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-matplotlib)](https://napari-hub.org/plugins/napari-matplotlib) A plugin to create Matplotlib plots from napari layers diff --git a/src/napari_matplotlib/scatter.py b/src/napari_matplotlib/scatter.py index 960a77d5..3b0f918c 100644 --- a/src/napari_matplotlib/scatter.py +++ b/src/napari_matplotlib/scatter.py @@ -4,6 +4,7 @@ import napari import numpy as np from magicgui import magicgui +from magicgui.widgets import ComboBox from .base import NapariMPLWidget from .util import Interval @@ -135,7 +136,7 @@ def x_axis_key(self) -> Optional[str]: return self._x_axis_key @x_axis_key.setter - def x_axis_key(self, key: Optional[str]): + def x_axis_key(self, key: Optional[str]) -> None: self._x_axis_key = key self._draw() @@ -145,17 +146,19 @@ def y_axis_key(self) -> Optional[str]: return self._y_axis_key @y_axis_key.setter - def y_axis_key(self, key: Optional[str]): + def y_axis_key(self, key: Optional[str]) -> None: self._y_axis_key = key self._draw() - def _set_axis_keys(self, x_axis_key: str, y_axis_key: str): + def _set_axis_keys(self, x_axis_key: str, y_axis_key: str) -> None: """Set both axis keys and then redraw the plot""" self._x_axis_key = x_axis_key self._y_axis_key = y_axis_key self._draw() - def _get_valid_axis_keys(self, combo_widget=None) -> List[str]: + def _get_valid_axis_keys( + self, combo_widget: Optional[ComboBox] = None + ) -> List[str]: """ Get the valid axis keys from the layer FeatureTable. @@ -188,7 +191,7 @@ def _get_data(self) -> Tuple[List[np.ndarray], str, str]: if not hasattr(self.layers[0], "features"): # if the selected layer doesn't have a featuretable, # skip draw - return np.array([]), "", "" + return [], "", "" feature_table = self.layers[0].features @@ -197,7 +200,7 @@ def _get_data(self) -> Tuple[List[np.ndarray], str, str]: or (self.x_axis_key is None) or (self.y_axis_key is None) ): - return np.array([]), "", "" + return [], "", "" data_x = feature_table[self.x_axis_key] data_y = feature_table[self.y_axis_key]