Skip to content

Commit 36334de

Browse files
authored
Merge pull request #26212 from QuLogic/old-types
Avoid deprecated typing hints
2 parents 3c38700 + d809a12 commit 36334de

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

lib/matplotlib/_path.pyi

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
2+
23
import numpy as np
4+
35
from .transforms import BboxBase
46

57
def affine_transform(points: np.ndarray, trans: np.ndarray) -> np.ndarray: ...

lib/matplotlib/cbook.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ from numpy.typing import ArrayLike
1111

1212
from typing import (
1313
Any,
14-
ContextManager,
1514
Generic,
1615
IO,
1716
Literal,
@@ -68,7 +67,7 @@ def open_file_cm(
6867
path_or_file: str | os.PathLike | IO,
6968
mode: str = ...,
7069
encoding: str | None = ...,
71-
) -> ContextManager[IO]: ...
70+
) -> contextlib.AbstractContextManager[IO]: ...
7271
def is_scalar_or_string(val: Any) -> bool: ...
7372
@overload
7473
def get_sample_data(

lib/matplotlib/pyplot.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,14 @@
8181
from typing import TYPE_CHECKING
8282

8383
if TYPE_CHECKING:
84+
from collections.abc import Callable, Hashable, Iterable, Sequence
8485
import datetime
8586
import pathlib
8687
import os
88+
from typing import Any, BinaryIO, Literal
8789

8890
import PIL
89-
9091
from numpy.typing import ArrayLike
91-
from typing import (
92-
Any, BinaryIO, Callable, Hashable, Literal, Sequence, Iterable, Type
93-
)
9492

9593
from matplotlib.axis import Tick
9694
from matplotlib.axes._base import _AxesBase
@@ -229,7 +227,7 @@ def set_loglevel(*args, **kwargs) -> None:
229227
@_copy_docstring_and_deprecators(Artist.findobj)
230228
def findobj(
231229
o: Artist | None = None,
232-
match: Callable[[Artist], bool] | Type[Artist] | None = None,
230+
match: Callable[[Artist], bool] | type[Artist] | None = None,
233231
include_self: bool = True
234232
) -> list[Artist]:
235233
if o is None:
@@ -751,7 +749,7 @@ def figure(
751749
# defaults to rc figure.edgecolor
752750
edgecolor: ColorType | None = None,
753751
frameon: bool = True,
754-
FigureClass: Type[Figure] = Figure,
752+
FigureClass: type[Figure] = Figure,
755753
clear: bool = False,
756754
**kwargs
757755
) -> Figure:

lib/matplotlib/typing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
The ``typing`` module and type stub files are considered provisional and may change
1010
at any time without a deprecation period.
1111
"""
12-
from collections.abc import Sequence
12+
from collections.abc import Hashable, Sequence
1313
import pathlib
14-
from typing import Any, Hashable, Literal, Union
14+
from typing import Any, Literal, Union
1515

1616
from . import path
1717
from ._enums import JoinStyle, CapStyle

0 commit comments

Comments
 (0)