Skip to content

CI: Resolve mypy stubtest build errors #28978

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
Oct 15, 2024
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
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import matplotlib.text as mtext
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
import mpl_toolkits.axisartist as AA # type: ignore
import mpl_toolkits.axisartist as AA # type: ignore[import]
from numpy.testing import (
assert_allclose, assert_array_equal, assert_array_almost_equal)
from matplotlib.testing.decorators import (
Expand Down Expand Up @@ -2976,7 +2976,7 @@ def test_scatter_singular_plural_arguments(self):


def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
return (c, edgecolors, kwargs if kwargs is not None else {}, xsize)
return (c, edgecolors, kwargs, xsize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kwargs defaults to a dict if not provided, so the check here was redundant and raising an error

_result = namedtuple('_result', 'c, colors')


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def test_correct_key():
pytest.xfail("test_widget_send_event is not triggering key_press_event")

from gi.repository import Gdk, Gtk # type: ignore
from gi.repository import Gdk, Gtk # type: ignore[import]

Check warning on line 10 in lib/matplotlib/tests/test_backend_gtk3.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/tests/test_backend_gtk3.py#L10

Added line #L10 was not covered by tests
fig = plt.figure()
buf = []

Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/tests/test_backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from matplotlib import _c_internal_utils

try:
from matplotlib.backends.qt_compat import QtGui, QtWidgets # type: ignore # noqa
from matplotlib.backends.qt_compat import QtGui # type: ignore[attr-defined] # noqa: E501, F401
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this import even though unused in order to smoke test the module

from matplotlib.backends.qt_compat import QtWidgets # type: ignore[attr-defined]
from matplotlib.backends.qt_editor import _formlayout
except ImportError:
pytestmark = pytest.mark.skip('No usable Qt bindings')
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _get_available_interactive_backends():
reason = "macosx backend fails on Azure"
elif env["MPLBACKEND"].startswith('gtk'):
try:
import gi # type: ignore
import gi # type: ignore[import]
except ImportError:
# Though we check that `gi` exists above, it is possible that its
# C-level dependencies are not available, and then it still raises an
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_simple():


def test_override_builtins():
import pylab # type: ignore
import pylab # type: ignore[import]
ok_to_override = {
'__name__',
'__doc__',
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def dummy(self): pass


class Unhashable:
__hash__ = None # type: ignore
__hash__ = None # type: ignore[assignment]
def dummy(self): pass


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def test_EllipseCollection_setter_getter():

@image_comparison(['polycollection_close.png'], remove_text=True, style='mpl20')
def test_polycollection_close():
from mpl_toolkits.mplot3d import Axes3D # type: ignore
from mpl_toolkits.mplot3d import Axes3D # type: ignore[import]
plt.rcParams['axes3d.automargin'] = True

vertsQuad = [
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ def test_ndarray_subclass_norm():
# which objects when adding or subtracting with other
# arrays. See #6622 and #8696
class MyArray(np.ndarray):
def __isub__(self, other): # type: ignore
def __isub__(self, other): # type: ignore[misc]
raise RuntimeError

def __add__(self, other):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def test_warn_mixed_args_and_kwargs(self):
"be discarded.")

def test_parasite(self):
from mpl_toolkits.axes_grid1 import host_subplot # type: ignore
from mpl_toolkits.axes_grid1 import host_subplot # type: ignore[import]

host = host_subplot(111)
par = host.twinx()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import matplotlib.figure as mfigure
from mpl_toolkits.axes_grid1 import axes_divider, parasite_axes # type: ignore
from mpl_toolkits.axes_grid1 import axes_divider, parasite_axes # type: ignore[import]


def test_simple():
Expand Down
Loading