diff --git a/pymassspec_plot/__init__.py b/pymassspec_plot/__init__.py index 91f4022..ec57696 100644 --- a/pymassspec_plot/__init__.py +++ b/pymassspec_plot/__init__.py @@ -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 diff --git a/pymassspec_plot/utils.py b/pymassspec_plot/utils.py index 9527f09..543afc8 100644 --- a/pymassspec_plot/utils.py +++ b/pymassspec_plot/utils.py @@ -26,7 +26,7 @@ ################################################################################ # 3rd party -from pyms.Spectrum import MassSpectrum # type: ignore[import] +from pyms.Spectrum import MassSpectrum __all__ = ["invert_mass_spec"] diff --git a/repo_helper.yml b/repo_helper.yml index a23d82d..ab51462 100644 --- a/repo_helper.yml +++ b/repo_helper.yml @@ -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: diff --git a/tests/conftest.py b/tests/conftest.py index 8f58000..9aa9a35 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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", ) diff --git a/tests/test_plot.py b/tests/test_plot.py index ab46bc0..e5e9fc1 100644 --- a/tests/test_plot.py +++ b/tests/test_plot.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -281,23 +281,33 @@ 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): @@ -305,7 +315,7 @@ def test_plot_peaks(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="'peak_list' must be a list of Peak objects"): - plot_peaks(ax, obj) + plot_peaks(ax, obj) # type: ignore[arg-type] @check_images diff --git a/tests/test_utils.py b/tests/test_utils.py index 8aa41f1..35aa2f5 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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 diff --git a/tox.ini b/tox.ini index 65480b7..a797032 100644 --- a/tox.ini +++ b/tox.ini @@ -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}