8000 Initially make mypy pass for tests · matplotlib/matplotlib@5dff3ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dff3ca

Browse files
committed
Initially make mypy pass for tests
1 parent f9de8aa commit 5dff3ca

17 files changed

+16
-10
lines changed

lib/matplotlib/_c_internal_utils.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def display_is_valid() -> bool: ...

lib/matplotlib/_image.pyi

Whitespace-only changes.

lib/matplotlib/_path.pyi

Whitespace-only changes.

lib/matplotlib/_qhull.pyi

Whitespace-only changes.

lib/matplotlib/_tri.pyi

Whitespace-only changes.

lib/matplotlib/_ttconv.pyi

Whitespace-only changes.

lib/matplotlib/backends/_backend_agg.pyi

Whitespace-only changes.

lib/matplotlib/backends/_macosx.pyi

Whitespace-only changes.

lib/matplotlib/backends/_tkagg.pyi

Whitespace-only changes.

lib/matplotlib/ft2font.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class FT2Font:
2+
def __init__(self, filename: str|os.PathLike, hinting_factor: int = ..., *, _fallback_list: list["FT2Font"]|None = ..., _kerning_factor: int = ...): ...
3+

lib/matplotlib/py.typed

Whitespace-only changes.

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
try:
21-
from matplotlib.backends.qt_compat import QtGui, QtWidgets # noqa
21+
from matplotlib.backends.qt_compat import QtGui, QtWidgets # type: ignore # noqa
2222
from matplotlib.backends.qt_editor import _formlayout
2323
except ImportError:
2424
pytestmark = pytest.mark.skip('No usable Qt bindings')

lib/matplotlib/tests/test_cbook.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import itertools
22
import pickle
33

4+
from typing import Any
45
from weakref import ref
56
from unittest.mock import patch, Mock
67

@@ -441,12 +442,12 @@ def test_sanitize_sequence():
441442
assert k == cbook.sanitize_sequence(k)
442443

443444

444-
fail_mapping = (
445+
fail_mapping: tuple[tuple[dict, dict], ...] = (
445446
({'a': 1, 'b': 2}, {'alias_mapping': {'a': ['b']}}),
446447
({'a': 1, 'b': 2}, {'alias_mapping': {'a': ['a', 'b']}}),
447448
)
448449

449-
pass_mapping = (
450+
pass_mapping: tuple[tuple[Any, dict, dict], ...] = (
450451
(None, {}, {}),
451452
({'a': 1, 'b': 2}, {'a': 1, 'b': 2}, {}),
452453
({'b': 2}, {'a': 2}, {'alias_mapping': {'a': ['a', 'b']}}),

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ def test_ndarray_subclass_norm():
13371337
# which objects when adding or subtracting with other
13381338
# arrays. See #6622 and #8696
13391339
class MyArray(np.ndarray):
1340-
def __isub__(self, other):
1340+
def __isub__(self, other): # type: ignore
13411341
raise RuntimeError
13421342

13431343
def __add__(self, other):

lib/matplotlib/tests/test_mathtext.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
import shlex
66
from xml.etree import ElementTree as ET
7+
from typing import Any
78

89
import numpy as np
910
import pytest
@@ -146,7 +147,7 @@
146147
# stub should be of the form (None, N) where N is the number of strings that
147148
# used to be tested
148149
# Add new tests at the end.
149-
font_test_specs = [
150+
font_test_specs: list[tuple[None|list[str], Any]] = [
150151
([], all),
151152
(['mathrm'], all),
152153
(['mathbf'], all),
@@ -170,10 +171,10 @@
170171
(['mathbf', 'mathsf'], [digits, uppercase, lowercase])
171172
]
172173

173-
font_tests = []
174+
font_tests: list[None|str] = []
174175
for fonts, chars in font_test_specs:
175176
if fonts is None:
176-
font_tests.extend([None] * chars)
177+
font_tests.extend([None] * chars) # type: ignore
177178
else:
178179
wrapper = ''.join([
179180
' '.join(fonts),

lib/matplotlib/tests/test_offsetbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_get_packed_offsets(widths, total, sep, mode):
137137
_get_packed_offsets(widths, total, sep, mode=mode)
138138

139139

140-
_Params = namedtuple('_params', 'wd_list, total, sep, expected')
140+
_Params = namedtuple('_Params', 'wd_list, total, sep, expected')
141141

142142

143143
@pytest.mark.parametrize('widths, total, sep, expected', [

lib/matplotlib/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,13 +1292,13 @@ class Transform(TransformNode):
12921292
- :meth:`transform_path`
12931293
"""
12941294

1295-
input_dims = None
1295+
input_dims: int|None = None
12961296
"""
12971297
The number of input dimensions of this transform.
12981298
Must be overridden (with integers) in the subclass.
12991299
"""
13001300

1301-
output_dims = None
1301+
output_dims: int|None = None
13021302
"""
13031303
The number of output dimensions of this transform.
13041304
Must be overridden (with integers) in the subclass.

0 commit comments

Comments
 (0)
0