Skip to content

Increase mypy strictness #50

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

Merged
merged 1 commit into from
May 19, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ repos:
rev: v0.910-1
hooks:
- id: mypy
args: ["--disallow-incomplete-defs", "--ignore-missing-imports"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions src/napari_matplotlib/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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.

Expand Down Expand Up @@ -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

Expand All @@ -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]
Expand Down