Skip to content

Commit

Permalink
Bump mypy version and update ignores.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Mar 5, 2024
1 parent 2597393 commit 102f65d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 40 deletions.
22 changes: 11 additions & 11 deletions pymassspec_plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
from typing import List, Mapping, Optional, Sequence, Tuple

# 3rd party
import matplotlib # type: ignore[import]
import matplotlib.pyplot as plt # type: ignore[import]
from matplotlib.axes import Axes # type: ignore[import]
from matplotlib.backend_bases import MouseEvent # type: ignore[import]
from matplotlib.container import BarContainer # type: ignore[import]
from matplotlib.figure import Figure # type: ignore[import]
from matplotlib.lines import Line2D # type: ignore[import]
from pyms import Peak # type: ignore[import]
from pyms.IonChromatogram import IonChromatogram # type: ignore[import]
from pyms.Peak.List.Function import is_peak_list # type: ignore[import]
from pyms.Spectrum import MassSpectrum, normalize_mass_spec # type: ignore[import]
import matplotlib # type: ignore[import-untyped]
import matplotlib.pyplot as plt # type: ignore[import-untyped]
from matplotlib.axes import Axes # type: ignore[import-untyped]
from matplotlib.backend_bases import MouseEvent # type: ignore[import-untyped]
from matplotlib.container import BarContainer # type: ignore[import-untyped]
from matplotlib.figure import Figure # type: ignore[import-untyped]
from matplotlib.lines import Line2D # type: ignore[import-untyped]
from pyms import Peak
from pyms.IonChromatogram import IonChromatogram
from pyms.Peak.List.Function import is_peak_list
from pyms.Spectrum import MassSpectrum, normalize_mass_spec

# this package
from pymassspec_plot.utils import invert_mass_spec
Expand Down
2 changes: 1 addition & 1 deletion pymassspec_plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
################################################################################

# 3rd party
from pyms.Spectrum import MassSpectrum # type: ignore[import]
from pyms.Spectrum import MassSpectrum

__all__ = ["invert_mass_spec"]

Expand Down
1 change: 1 addition & 0 deletions repo_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ min_coverage: 88
use_whey: true
sphinx_html_theme: furo
python_deploy_version: 3.8
mypy_version: "1.8.0"
preserve_custom_theme: true

conda_channels:
Expand Down
18 changes: 9 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import numpy
import pytest
from domdf_python_tools.paths import PathPlus
from pyms.BillerBiemann import BillerBiemann # type: ignore[import]
from pyms.GCMS.Class import GCMS_data # type: ignore[import]
from pyms.GCMS.IO.JCAMP import JCAMP_reader # type: ignore[import]
from pyms.IntensityMatrix import IntensityMatrix, build_intensity_matrix_i # type: ignore[import]
from pyms.IonChromatogram import IonChromatogram # type: ignore[import]
from pyms.Noise.SavitzkyGolay import savitzky_golay # type: ignore[import]
from pyms.Peak import Peak # type: ignore[import]
from pyms.Spectrum import MassSpectrum # type: ignore[import]
from pyms.TopHat import tophat # type: ignore[import]
from pyms.BillerBiemann import BillerBiemann
from pyms.GCMS.Class import GCMS_data
from pyms.GCMS.IO.JCAMP import JCAMP_reader
from pyms.IntensityMatrix import IntensityMatrix, build_intensity_matrix_i
from pyms.IonChromatogram import IonChromatogram
from pyms.Noise.SavitzkyGolay import savitzky_golay
from pyms.Peak import Peak
from pyms.Spectrum import MassSpectrum
from pyms.TopHat import tophat
from pytest_regressions.data_regression import RegressionYamlDumper

pytest_plugins = ("coincidence", )
Expand Down
44 changes: 27 additions & 17 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import pytest
from coincidence.regressions import AdvancedFileRegressionFixture
from domdf_python_tools.paths import PathPlus
from matplotlib import pyplot as plt # type: ignore[import]
from matplotlib.backend_bases import MouseEvent # type: ignore[import]
from matplotlib.cbook import CallbackRegistry # type: ignore[import]
from matplotlib.figure import Figure # type: ignore[import]
from pyms.GCMS.Class import GCMS_data # type: ignore[import]
from pyms.IntensityMatrix import IntensityMatrix # type: ignore[import]
from pyms.IonChromatogram import IonChromatogram # type: ignore[import]
from pyms.Peak import Peak # type: ignore[import]
from pyms.Spectrum import MassSpectrum # type: ignore[import]
from matplotlib import pyplot as plt # type: ignore[import-untyped]
from matplotlib.backend_bases import MouseEvent # type: ignore[import-untyped]
from matplotlib.cbook import CallbackRegistry # type: ignore[import-untyped]
from matplotlib.figure import Figure # type: ignore[import-untyped]
from pyms.GCMS.Class import GCMS_data
from pyms.IntensityMatrix import IntensityMatrix
from pyms.IonChromatogram import IonChromatogram
from pyms.Peak import Peak
from pyms.Spectrum import MassSpectrum

# this package
from pymassspec_plot import ClickEventHandler, plot_head2tail, plot_ic, plot_mass_spec, plot_peaks
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_plot_ic_errors(im_i: IntensityMatrix, data: GCMS_data, ms: MassSpectrum

for obj in [*test_sequences, test_string, *test_numbers, test_dict, im_i, data, ms]:
with pytest.raises(TypeError, match="'ic' must be an IonChromatogram"):
plot_ic(ax, obj)
plot_ic(ax, obj) # type: ignore[arg-type]


# Plotting tic with various Line2D options
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_plot_tic_errors(im_i: IntensityMatrix, data: GCMS_data, ms: MassSpectru
ms,
]:
with pytest.raises(TypeError, match="'ic' must be an IonChromatogram"):
plot_ic(ax, obj)
plot_ic(ax, obj) # type: ignore[arg-type]


@check_images
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_plot_mass_spec_errors(im_i: IntensityMatrix, data: GCMS_data, tic: IonC
tic,
]:
with pytest.raises(TypeError, match="'mass_spec' must be a MassSpectrum"):
plot_mass_spec(ax, obj)
plot_mass_spec(ax, obj) # type: ignore[arg-type]


@check_images
Expand Down Expand Up @@ -281,31 +281,41 @@ def test_plot_head2tail_errors(im_i: IntensityMatrix, data: GCMS_data):

for obj in [*test_sequences, test_string, *test_numbers, test_dict, im_i, data]:
with pytest.raises(TypeError, match="'top_mass_spec' must be a MassSpectrum"):
plot_head2tail(ax, obj, im_i.get_ms_at_index(150))
plot_head2tail(ax, obj, im_i.get_ms_at_index(150)) # type: ignore[arg-type]

with pytest.raises(TypeError, match="'bottom_mass_spec' must be a MassSpectrum"):
plot_head2tail(ax, im_i.get_ms_at_index(50), obj)
plot_head2tail(ax, im_i.get_ms_at_index(50), obj) # type: ignore[arg-type]

for obj in [*test_sequences, test_string, *test_numbers, im_i.get_ms_at_index(250), im_i, data]:
with pytest.raises(
TypeError,
match="'top_spec_kwargs' must be a mapping of keyword arguments for the top mass spectrum."
):
plot_head2tail(ax, im_i.get_ms_at_index(50), im_i.get_ms_at_index(150), top_spec_kwargs=obj)
plot_head2tail(
ax,
im_i.get_ms_at_index(50),
im_i.get_ms_at_index(150),
top_spec_kwargs=obj, # type: ignore[arg-type]
)

with pytest.raises(
TypeError,
match="'bottom_spec_kwargs' must be a mapping of keyword arguments for the bottom mass spectrum."
):
plot_head2tail(ax, im_i.get_ms_at_index(50), im_i.get_ms_at_index(150), bottom_spec_kwargs=obj)
plot_head2tail(
ax,
im_i.get_ms_at_index(50),
im_i.get_ms_at_index(150),
bottom_spec_kwargs=obj, # type: ignore[arg-type]
)


def test_plot_peaks(im_i: IntensityMatrix, data: GCMS_data, ms: MassSpectrum):
fig, ax = plt.subplots()

for obj in [*test_sequences, test_string, *test_numbers, test_dict, im_i, data, ms]:
with pytest.raises(TypeError, match="'peak_list' must be a list of Peak objects"):
plot_peaks(ax, obj)
plot_peaks(ax, obj) # type: ignore[arg-type]


@check_images
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 3rd party
from coincidence import AdvancedDataRegressionFixture
from pyms.Spectrum import MassSpectrum # type: ignore
from pyms.Spectrum import MassSpectrum

# this package
from pymassspec_plot import invert_mass_spec
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ basepython = python3.8
ignore_errors = True
changedir = {toxinidir}
deps =
mypy==0.971
mypy==1.8.0
-r{toxinidir}/tests/requirements.txt
commands = mypy pymassspec_plot tests {posargs}

Expand Down

0 comments on commit 102f65d

Please sign in to comment.